diff --git a/examples/walk-test.js b/examples/walk-test.js index 8045a49..d21f37a 100755 --- a/examples/walk-test.js +++ b/examples/walk-test.js @@ -2,9 +2,11 @@ (function () { "use strict"; - var walk = require('../lib/walk'), - count = 0, - saneCount = 0; + var walk = require('walk') + , count = 0 + , emitter + , saneCount = 0 + ; function sort(a,b) { a= a.toLowerCase(); @@ -16,7 +18,7 @@ process.argv.forEach(function(startpath, index) { if (index > 1) { - emitter = walk(startpath); + emitter = walk.walk(startpath); // Non-`stat`ed Nodes emitter.on('name', function (path, file, stat) { diff --git a/package.json b/lib/package.json similarity index 68% rename from package.json rename to lib/package.json index 287c2fb..c6aa384 100644 --- a/package.json +++ b/lib/package.json @@ -6,9 +6,9 @@ "author" : "AJ ONeal ", "contributors" : [], "dependencies" : { - "futures": ">= 1.9.2" + "Array.prototype.forEachAsync": ">= 2.1.0" }, - "lib" : "lib", - "main" : "./lib/walk.js", - "version" : "2.0.0" + "lib" : ".", + "main" : "./walk.js", + "version" : "2.0.1" } diff --git a/lib/walk.js b/lib/walk.js index 4ff2745..99533dd 100644 --- a/lib/walk.js +++ b/lib/walk.js @@ -3,7 +3,7 @@ "use strict" // Array.prototype.forEachAsync(next, item, i, collection) - require('futures/forEachAsync'); + require('Array.prototype.forEachAsync'); function noop() {} diff --git a/profile/walk-test.js b/profile/walk-test.js new file mode 100755 index 0000000..8045a49 --- /dev/null +++ b/profile/walk-test.js @@ -0,0 +1,129 @@ +#!/usr/bin/env node +(function () { + "use strict"; + + var walk = require('../lib/walk'), + count = 0, + saneCount = 0; + + function sort(a,b) { + a= a.toLowerCase(); + b= b.toLowerCase(); + if (a > b) return -1; + if (a < b) return 1; + return 0; + } + + process.argv.forEach(function(startpath, index) { + if (index > 1) { + emitter = walk(startpath); + + // Non-`stat`ed Nodes + emitter.on('name', function (path, file, stat) { + saneCount += 1; + //console.log( ["[", count, "] ", path, '/', file].join('') ) + //console.log( [path, '/', file].join('') ) + }); + emitter.on('names', function (path, files, stats) { + files.sort(sort); + //console.log('sort: ' + files.join(' ; ')); + }); + + + + // Single `stat`ed Nodes + emitter.on('error', function (path, err, next) { + next() + // ignore + }); + emitter.on('directoryError', function (path, stats, next) { + next(); + }); + emitter.on('nodeError', function (path, stats, next) { + next(); + }); + /* + emitter.on('node', function (path, stat, next) { + count += 1; + console.log( [path, '/', stat.name].join('') ) + //console.log( ["[", count, "] ", path, '/', stat.name].join('') ) + next(); + }); + */ + emitter.on('file', function (path, stat, next) { + count += 1; + console.log( [path, '/', stat.name].join('') ) + //console.log( ["[", count, "] ", path, '/', stat.name].join('') ) + next(); + }); + emitter.on('directory', function (path, stat, next) { + count += 1; + console.log( [path, '/', stat.name].join('') ) + next(); + }); + emitter.on('symbolicLink', function (path, stat, next) { + count += 1; + console.log( [path, '/', stat.name].join('') ) + next(); + }); + /* + emitter.on('blockDevice', function (path, stat, next) { + next(); + }); + emitter.on('characterDevice', function (path, stat, next) { + next(); + }); + emitter.on('FIFO', function (path, stat, next) { + next(); + }); + emitter.on('socket', function (path, stat, next) { + next(); + }); + */ + + + + // Grouped `stat`ed Nodes + emitter.on('errors', function (path, stats, next) { + next(); + }); + /* + emitter.on('nodes', function (path, stats, next) { + next(); + }); + */ + emitter.on('files', function (path, stats, next) { + next(); + }); + emitter.on('directories', function (path, stats, next) { + //delete stats[1]; + next(); + }); + emitter.on('symbolicLinks', function (path, stats, next) { + next(); + }); + /* + emitter.on('blockDevices', function (path, stats, next) { + next(); + }); + emitter.on('characterDevices', function (path, stats, next) { + next(); + }); + emitter.on('FIFOs', function (path, stats, next) { + next(); + }); + emitter.on('sockets', function (path, stats, next) { + next(); + }); + */ + + + + // The end of all things + emitter.on('end', function () { + console.log("The eagle has landed. [" + count + " == " + saneCount + "]"); + }); + } + }); + +}());