fwalker.js
function Walker () {
  var self = this;

  var walkSync = function (dir, trace, callback) {
    fs.readdirSync(dir).forEach(function (name) {
      var file = path.join(dir, name)
        , stat = fs.lstatSync(file)
        , isDir = stat.isDirectory()
        , _trace = trace;
      try {
        callback(name, file, isDir, function () {
          return _trace.slice(0);
        });
      }
      finally {
        _trace = null;
      }
      if (isDir) {
        trace.push(name);
        try {
          walkSync(file, trace, callback);
        }
        finally {
          trace.pop();
        }
      }
    });
  };

  /**
   * Traverse the directory synchronously.
   *
   * Parameters
   * - dir: A directory to traverse
   * - callback: A function to be called for each file recursively
   *
   * Returns: The list of information of files contained in 'dir'
   */
  self.walkSync = function (dir, callback) {
    if (typeof callback != 'function') {
      throw new Error("'callback' is not a function.");
    }
    walkSync(dir, [], callback);
  };
}
function Walker () {
  var self = this;

  var walkSync = function (dir, trace, callback) {
    fs.readdirSync(dir).forEach(function (name) {
      var file = path.join(dir, name)
        , stat = fs.lstatSync(file)
        , isDir = stat.isDirectory()
        , _trace = trace;
      try {
        callback(name, file, isDir, function () {
          return _trace.slice(0);
        });
      }
      finally {
        _trace = null;
      }
      if (isDir) {
        trace.push(name);
        try {
          walkSync(file, trace, callback);
        }
        finally {
          trace.pop();
        }
      }
    });
  };

  /**
   * Traverse the directory synchronously.
   *
   * Parameters
   * - dir: A directory to traverse
   * - callback: A function to be called for each file recursively
   *
   * Returns: The list of information of files contained in 'dir'
   */
  self.walkSync = function (dir, callback) {
    if (typeof callback != 'function') {
      throw new Error("'callback' is not a function.");
    }
    walkSync(dir, [], callback);
  };
}
function Walker ( ) { var self = this ; var walkSync = function ( dir , trace , callback ) { fs . readdirSync ( dir ) . forEach ( function ( name ) { var file = path . join ( dir , name ) , stat = fs . lstatSync ( file ) , isDir = stat . isDirectory ( ) , _trace = trace ; try { callback ( name , file , isDir , function ( ) { return _trace . slice ( 0 ) ; } ) ; } finally { _trace = null ; } if ( isDir ) { trace . push ( name ) ; try { walkSync ( file , trace , callback ) ; } finally { trace . pop ( ) ; } } } ) ; } ; /**
   * Traverse the directory synchronously.
   *
   * Parameters
   * - dir: A directory to traverse
   * - callback: A function to be called for each file recursively
   *
   * Returns: The list of information of files contained in 'dir'
   */ self . walkSync = function ( dir , callback ) { if ( typeof callback != 'function' ) { throw new Error ( "'callback' is not a function." ) ; } walkSync ( dir , [ ] , callback ) ; } ; }
Initialize a new instance of the simple file traversal modules.
Initialize a new instance of the simple file traversal modules .