Comparing version 0.2.9 to 0.2.10
@@ -5,37 +5,46 @@ // Read all filenames from directory and it's subdirectories | ||
var call = Function.prototype.call | ||
, fs = require('fs') | ||
, aritize = require('es5-ext/lib/Function/prototype/aritize') | ||
, invoke = require('es5-ext/lib/Function/invoke') | ||
, k = require('es5-ext/lib/Function/k') | ||
, flatten = call.bind(require('es5-ext/lib/Array/prototype/flatten')) | ||
, deferred = require('deferred') | ||
, concat = aritize.call(String.prototype.concat, 1) | ||
var readdir = require('fs').readdir | ||
, normalize = require('../path/normalize') | ||
, readdir = deferred.promisify(fs.readdir) | ||
, stat = deferred.promisify(fs.lstat); | ||
, read; | ||
module.exports = function self (path, callback) { | ||
readdir(path = normalize(path)) | ||
(function (files) { | ||
return deferred.map(files, function (file) { | ||
var npath = normalize(path + '/' + file); | ||
return stat(npath) | ||
(function (stats) { | ||
if (stats.isFile()) { | ||
return file; | ||
} else if (stats.isDirectory()) { | ||
return deferred.promisify(self)(npath) | ||
(invoke('map', function (subfile) { | ||
return normalize(file + '/' + subfile); | ||
read = function (path, files, cb) { | ||
var waiting = files.length, result = []; | ||
if (!waiting) { | ||
cb(null, result); | ||
return; | ||
} | ||
files.forEach(function (file) { | ||
readdir(path + '/' + file, function (err, files) { | ||
if (err) { | ||
switch (err.code) { | ||
case "UNKNOWN": | ||
case "ENOTDIR": | ||
result.push(file); | ||
} | ||
if (!--waiting) { | ||
cb(null, result); | ||
} | ||
} else { | ||
read(path + '/' + file, files, function (err, res) { | ||
result = result.concat(res.map(function (name) { | ||
return normalize(file + '/' + name); | ||
})); | ||
} else { | ||
return null; | ||
} | ||
}, file); | ||
}) | ||
(invoke('filter', Boolean)) | ||
(flatten); | ||
}).end(callback); | ||
if (!--waiting) { | ||
cb(null, result); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
}; | ||
module.exports = function self (path, cb) { | ||
readdir(path = normalize(path), function (err, files) { | ||
if (err) { | ||
cb(err); | ||
return; | ||
} | ||
read(path, files, cb); | ||
}); | ||
}; |
{ | ||
"name": "next", | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"description": "Node.js extensions", | ||
@@ -5,0 +5,0 @@ "keywords": ["node", "nodejs", "node.js", "extensions", "addons", "extras"], |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
885
29281