lib/file-emitter.js
function FileEmitter(folder, opt_options) {
  if (!(this instanceof FileEmitter)) {
    return new FileEmitter(folder, opt_options);
  }
  events.EventEmitter.call(this);
  opt_options = opt_options || {};

  this.root = path.resolve(process.cwd(), folder);

  // flags & options
  this.buffer = opt_options.buffer || false;
  this.incremental = opt_options.incremental || false;
  this.followSymLinks = opt_options.followSymLinks || false;
  this.recursive = opt_options.recursive === false ? false : true;
  this.maxBufferSize = opt_options.maxBufferSize || 10485760; // 10 MiB

  // file constructor
  this.File = opt_options.File || File;

  // filters
  this.include = opt_options.include || false;
  this.exclude = opt_options.exclude || false;
  this._minimatchOptions = opt_options.minimatchOptions || {matchBase: true};

  // read, stat & readdir queues
  this._queues = [[], [], ['']];

  // max number of open file descriptors (used for incremental EMFILE back-off)
  this._maxFDs = opt_options.maxFDs || Infinity; // UNDOCUMENTED OPTION
  // currently open file descriptors
  this._numFDs = 0;
  // incremental lock
  this._locked = false;
  this._hadError = false;

  var self = this;

  if (opt_options.autorun !== false) {
    setImmediate(function() {
      self.run();
    });
  }
}
function FileEmitter(folder, opt_options) {
  if (!(this instanceof FileEmitter)) {
    return new FileEmitter(folder, opt_options);
  }
  events.EventEmitter.call(this);
  opt_options = opt_options || {};

  this.root = path.resolve(process.cwd(), folder);

  // flags & options
  this.buffer = opt_options.buffer || false;
  this.incremental = opt_options.incremental || false;
  this.followSymLinks = opt_options.followSymLinks || false;
  this.recursive = opt_options.recursive === false ? false : true;
  this.maxBufferSize = opt_options.maxBufferSize || 10485760; // 10 MiB

  // file constructor
  this.File = opt_options.File || File;

  // filters
  this.include = opt_options.include || false;
  this.exclude = opt_options.exclude || false;
  this._minimatchOptions = opt_options.minimatchOptions || {matchBase: true};

  // read, stat & readdir queues
  this._queues = [[], [], ['']];

  // max number of open file descriptors (used for incremental EMFILE back-off)
  this._maxFDs = opt_options.maxFDs || Infinity; // UNDOCUMENTED OPTION
  // currently open file descriptors
  this._numFDs = 0;
  // incremental lock
  this._locked = false;
  this._hadError = false;

  var self = this;

  if (opt_options.autorun !== false) {
    setImmediate(function() {
      self.run();
    });
  }
}
function FileEmitter ( folder , opt_options ) { if ( ! ( this instanceof FileEmitter ) ) { return new FileEmitter ( folder , opt_options ) ; } events . EventEmitter . call ( this ) ; opt_options = opt_options || { } ; this . root = path . resolve ( process . cwd ( ) , folder ) ; // flags & options this . buffer = opt_options . buffer || false ; this . incremental = opt_options . incremental || false ; this . followSymLinks = opt_options . followSymLinks || false ; this . recursive = opt_options . recursive === false ? false : true ; this . maxBufferSize = opt_options . maxBufferSize || 10485760 ; // 10 MiB // file constructor this . File = opt_options . File || File ; // filters this . include = opt_options . include || false ; this . exclude = opt_options . exclude || false ; this . _minimatchOptions = opt_options . minimatchOptions || { matchBase : true } ; // read, stat & readdir queues this . _queues = [ [ ] , [ ] , [ '' ] ] ; // max number of open file descriptors (used for incremental EMFILE back-off) this . _maxFDs = opt_options . maxFDs || Infinity ; // UNDOCUMENTED OPTION // currently open file descriptors this . _numFDs = 0 ; // incremental lock this . _locked = false ; this . _hadError = false ; var self = this ; if ( opt_options . autorun !== false ) { setImmediate ( function ( ) { self . run ( ) ; } ) ; } }
file-emitter

**opt_options**
- `{boolean} buffer` Load each file into a buffer before emitting, defaults to `false`
- `{number} maxBufferSize` The max size of a file buffer, defaults to `10485760` (=10MiB)
- `{boolean} incremental` When `true` each `file` event has to be acknowledged by calling `fe.next()`
- `{boolean} followSymLinks` ..., defaults to `false`
- `{boolean} recursive` ..., defaults to `true`
- `{boolean} autorun` ..., defaults to `true`
- `{Array<string>} exclude` glob patterns applied after `readir`
- `{Array<string>} include` glob patterns applied after `stat`
- `{Object} minimatchOptions` See `minimatch` README, defaults to `{matchBase: true}`
- `{Function} File` A custom constructor for file objects, has to extend `File`

@param {string} folder
@param {?Object} opt_options

@constructor
file - emitter