# FileHound

#### new FileHound()

Source:
  - filehound.js, line 56

### Methods

#### (static) accessed(dateExpression)

Filters by file access time

##### Parameters:

Name | Type | Description
--- | --- | ---
`dateExpression` | string | date expression

Source:
  - filehound.js, line 129

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .accessed("< 10 minutes")
      .find()
      .each(console.log);

#### (static) any()

Returns all matches from one of more FileHound instances

Source:
  - filehound.js, line 85

##### Returns:

a promise containing all matches. If the Promise fulfils, the fulfilment value is an array of all matching files.

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.any(fh1, fh2);

#### (static) create()

Static factory method to create an instance of FileHound

Source:
  - filehound.js, line 68

##### Returns:

FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();

#### (static) modified(dateExpression)

Filters by modifiction time

##### Parameters:

Name | Type | Description
--- | --- | ---
`dateExpression` | string | date expression

Source:
  - filehound.js, line 104

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .modified("< 2 days")
      .find()
      .each(console.log);

#### addFilter(function)

##### Parameters:

Name | Type | Description
--- | --- | ---
`function` | function | custom filter function

Source:
  - filehound.js, line 180

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .addFilter(customFilter)
      .find()
      .each(consoe.log);

#### changed(dateExpression)

Filters change time

##### Parameters:

Name | Type | Description
--- | --- | ---
`dateExpression` | string | date expression

Source:
  - filehound.js, line 154

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .changed("< 10 minutes")
      .find()
      .each(console.log);

#### depth()

Specify the directory search depth. If set to zero, recursive searching will be disabled

Source:
  - filehound.js, line 512

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .depth(0)
      .find()
      .each(console.log); // array of files names only in the current directory

#### directory()

Find sub-directories

Source:
  - filehound.js, line 466

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .directory()
      .find()
      .each(console.log); // array of matching sub-directories

#### discard(regex)

Ignores files or sub-directories matching pattern

##### Parameters:

Name | Type | Description
--- | --- | ---
`regex` | string | array | regex or array of regex

Source:
  - filehound.js, line 247

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .discard("*.tmp*")
      .find()
      .each(console.log);

#### ext(extensions)

Filter on file extension

##### Parameters:

Name | Type | Description
--- | --- | ---
`extensions` | string | array | extension or an array of extensions

Source:
  - filehound.js, line 273

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    let filehound = FileHound.create();
    filehound
      .ext(".json")
      .find()
      .each(console.log);

    // array of extensions to filter by
    filehound = FileHound.create();
    filehound
      .ext([".json", ".txt"])
      .find()
      .each(console.log);

    // supports var args
    filehound = FileHound.create();
    filehound
      .ext(".json", ".txt")
      .find()
      .each(console.log);

#### find(function)

Asynchronously executes a file search.

##### Parameters:

Name | Type | Description
--- | --- | ---
`function` | function | Optionally accepts a callback function

Source:
  - filehound.js, line 535

##### Returns:

Returns a Promise of all matches. If the Promise fulfils, the fulfilment value is an array of all matching files

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .find()
      .each(console.log);

    // using a callback
    filehound
      .find((err, files) => {
         if (err) return console.error(err);

         console.log(files);
      });

#### findSync()

Synchronously executes a file search.

Source:
  - filehound.js, line 581

##### Returns:

Returns an array of all matching files

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    const files = filehound.findSync();
    console.log(files);

#### glob(glob)

Filter by a file glob

##### Parameters:

Name | Type | Description
--- | --- | ---
`glob` | string | file glob

Source:
  - filehound.js, line 363

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .glob("*tmp*")
      .find()
      .each(console.log); // array of files names all containing 'tmp'

#### ignoreHiddenDirectories()

Ignore hidden directories

Source:
  - filehound.js, line 444

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .ignoreHiddenDirectories()
      .find()
      .each(console.log); // array of files names that are not hidden directories

#### ignoreHiddenFiles()

Filter to ignore hidden files

Source:
  - filehound.js, line 420

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .ignoreHiddenFiles()
      .find()
      .each(console.log); // array of files names that are not hidden files

#### isEmpty(path)

Filter by zero length files

##### Parameters:

Name | Type | Description
--- | --- | ---
`path` | string | path

Source:
  - filehound.js, line 340

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .size("<10kb")
      .find()
      .each(console.log);

#### match()

Same as glob

Source:
  - filehound.js, line 389
See:
  - glob

#### not(glob)

Negates filters

##### Parameters:

Name | Type | Description
--- | --- | ---
`glob` | string | file glob

Source:
  - filehound.js, line 396

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .not()
      .glob("*tmp*")
      .find()
      .each(console.log); // array of files names NOT containing 'tmp'

#### path(path)

Define the search path

##### Parameters:

Name | Type | Description
--- | --- | ---
`path` | string | path

Source:
  - filehound.js, line 225

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .path("/tmp")
      .find()
      .each(console.log);

#### paths(path)

Defines the search paths

##### Parameters:

Name | Type | Description
--- | --- | ---
`path` | array | array of paths

Source:
  - filehound.js, line 202

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .paths("/tmp", "/etc") // or ["/tmp", "/etc"]
      .find()
      .each(console.log);

#### size(sizeExpression)

Filter by file size

##### Parameters:

Name | Type | Description
--- | --- | ---
`sizeExpression` | string | a size expression

Source:
  - filehound.js, line 314

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .size("<10kb")
      .find()
      .each(console.log);

#### socket()

Find sockets

Source:
  - filehound.js, line 488

##### Returns:

a FileHound instance

##### Example

    import FileHound from 'filehound';

    const filehound = FileHound.create();
    filehound
      .socket()
      .find()
      .each(console.log); // array of matching sockets