lib/gaze.js
function Gaze (patterns, opts, done) {
  EE.call(this);

  // If second arg is the callback
  if (typeof opts === 'function') {
    done = opts;
    opts = {};
  }

  // Default options
  opts = opts || {};
  opts.mark = true;
  opts.interval = opts.interval || 100;
  opts.debounceDelay = opts.debounceDelay || 500;
  opts.cwd = opts.cwd || process.cwd();
  this.options = opts;

  // Default done callback
  done = done || emptyFunction;

  // Remember our watched dir:files
  this._watched = Object.create(null);

  // Store watchers
  this._watchers = Object.create(null);

  // Store watchFile listeners
  this._pollers = Object.create(null);

  // Store patterns
  this._patterns = [];

  // Cached events for debouncing
  this._cached = Object.create(null);

  // Set maxListeners
  if (this.options.maxListeners != null) {
    this.setMaxListeners(this.options.maxListeners);
    delete this.options.maxListeners;
  }

  // Initialize the watch on files
  if (patterns) {
    this.add(patterns, done);
  }

  // keep the process alive
  this._keepalive = setInterval(emptyFunction, 200);

  return this;
}
function Gaze (patterns, opts, done) {
  EE.call(this);

  // If second arg is the callback
  if (typeof opts === 'function') {
    done = opts;
    opts = {};
  }

  // Default options
  opts = opts || {};
  opts.mark = true;
  opts.interval = opts.interval || 100;
  opts.debounceDelay = opts.debounceDelay || 500;
  opts.cwd = opts.cwd || process.cwd();
  this.options = opts;

  // Default done callback
  done = done || emptyFunction;

  // Remember our watched dir:files
  this._watched = Object.create(null);

  // Store watchers
  this._watchers = Object.create(null);

  // Store watchFile listeners
  this._pollers = Object.create(null);

  // Store patterns
  this._patterns = [];

  // Cached events for debouncing
  this._cached = Object.create(null);

  // Set maxListeners
  if (this.options.maxListeners != null) {
    this.setMaxListeners(this.options.maxListeners);
    delete this.options.maxListeners;
  }

  // Initialize the watch on files
  if (patterns) {
    this.add(patterns, done);
  }

  // keep the process alive
  this._keepalive = setInterval(emptyFunction, 200);

  return this;
}
function Gaze ( patterns , opts , done ) { EE . call ( this ) ; // If second arg is the callback if ( typeof opts === 'function' ) { done = opts ; opts = { } ; } // Default options opts = opts || { } ; opts . mark = true ; opts . interval = opts . interval || 100 ; opts . debounceDelay = opts . debounceDelay || 500 ; opts . cwd = opts . cwd || process . cwd ( ) ; this . options = opts ; // Default done callback done = done || emptyFunction ; // Remember our watched dir:files this . _watched = Object . create ( null ) ; // Store watchers this . _watchers = Object . create ( null ) ; // Store watchFile listeners this . _pollers = Object . create ( null ) ; // Store patterns this . _patterns = [ ] ; // Cached events for debouncing this . _cached = Object . create ( null ) ; // Set maxListeners if ( this . options . maxListeners != null ) { this . setMaxListeners ( this . options . maxListeners ) ; delete this . options . maxListeners ; } // Initialize the watch on files if ( patterns ) { this . add ( patterns , done ) ; } // keep the process alive this . _keepalive = setInterval ( emptyFunction , 200 ) ; return this ; }
`Gaze` EventEmitter object to return in the callback
Gaze EventEmitter object to return in the callback