lib/ndir.js
function Walk(root, onDir, onEnd, onError) {
  if (!(this instanceof Walk)) {
    return new Walk(root, onDir, onEnd, onError);
  }
  this.dirs = [path.resolve(root)];
  if (onDir) {
    this.on('dir', onDir);
  }
  if (onEnd) {
    this.on('end', onEnd);
  }
  onError && this.on('error', onError);
  var self = this;
  // let listen `files` Event first.
  process.nextTick(function () {
    self.next();
  });
}
function Walk(root, onDir, onEnd, onError) {
  if (!(this instanceof Walk)) {
    return new Walk(root, onDir, onEnd, onError);
  }
  this.dirs = [path.resolve(root)];
  if (onDir) {
    this.on('dir', onDir);
  }
  if (onEnd) {
    this.on('end', onEnd);
  }
  onError && this.on('error', onError);
  var self = this;
  // let listen `files` Event first.
  process.nextTick(function () {
    self.next();
  });
}
function Walk ( root , onDir , onEnd , onError ) { if ( ! ( this instanceof Walk ) ) { return new Walk ( root , onDir , onEnd , onError ) ; } this . dirs = [ path . resolve ( root ) ] ; if ( onDir ) { this . on ( 'dir' , onDir ) ; } if ( onEnd ) { this . on ( 'end' , onEnd ) ; } onError && this . on ( 'error' , onError ) ; var self = this ; // let listen `files` Event first. process . nextTick ( function ( ) { self . next ( ) ; } ) ; }
dir Walker Class.

@constructor
@param {String} root    Root path.
@param {Function(dirpath, files)} [onDir]   The `dir` event callback.
@param {Function} [onEnd]   The `end` event callback.
@param {Function(err)} [onError] The `error` event callback.
@public
dir Walker Class .