descriptorsHandler() (fs2/descriptors-handler)

To be used only in main modules. Never require it in generic module that may be required in others

How it works? If limit of descriptors is reached it holds the calls to native functions and releases them when taken descriptors are freed.

Internally it provides same solution as fs-graceful module with following differences:

Focuses only on file descriptors limit problem

Gives access to taken/available descriptors count and allows setting of limit by external module. Thanks to that we can also cover descriptors opened by fs.watch module (watch is bound to that module)

Covers readdir calls (which also happen to throw EMFILE errors)

More bulletproof (I assume) error handling logic

isIgnored(mode, path[, options[, cb]]) (fs2/is-ignored)

Whether file is ignored up to predefined rules. Returns promise but regular callback is also supported.

Rules are decided by mode argument. Currently only git mode is supported, in that case rules are searched in .gitignore files (Rules have effect only if placed in valid git repositories).
Other modes can be easily configured by extending _ignoreModes module (See lib/fs/_ignore-modes directory to see how it's done).

Supported options:

globalRulesstring|array - additional global rules. They will be matched as if placed in filesystem root directory, it means that any rules found in existing ignore files may override them.

watchbool - whether to watch for changes. If ignore state would change, returned promise would emit change event with new value (true/false)

readdir(path[, options[, cb]]) (fs2/readdir)

depthnumber- Level of recurse into subdirectories. Defaults to 0 which resembles behavior of native version. If you want to recurse without any nest limitation just provide Infinity

typeobject- Which type of files should be returned. By default all files are returned. Stats methods shows how many different types can be returned. To narrow it down provide a hash. e.g. { file: true, symbolicLink: true }.

patternregexp- Filter returned files by specific pattern. Pattern should be regular expression that would be matched against full path.

watchbool - Watch directory for changes. Changes are emitted on returned promise with data events. event object states which files were added (event.added) and which were removed (event.removed), Starting from next release (v0.4) this functionality will most likely be provided as valid Node.js stream

streambool - Whether to provide data continuously. Currently it's not provided as a stream per se (it would be starting from next release, v0.4), data is emited as data events on returned promise object, structure of event objects described under watch option

ignoreRulesstring|array - Whether to obey ignore rules found in ignore files. See fs.isIgnored for more information

globalRulesstring|array - Global rules that complement ignoreRules. See fs.isIgnored for more information.

watch(path) (fs2/watch)

Watch file for changes.fs.watch wrapper that works same way on every platform, always configured in persistent: false mode.
It's aware of open file descriptors limitations, if EMFILE error is approach, switch to alternative mode that pings file stats (see fs.watchFile) is made.