Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fs.readdir(path)(function (filepaths) {
filepaths = filepaths.map(function (filepath) { return path + "/" + filepath; });
Do.filter_map(filepaths, function (filepath, callback, errback) {
fs.stat(filepath)(function (stat) {
if (!stat.isFile()) { callback(); return ; }
fs.readFile(filepath)(function (data) {
callback([filepath, data]);
}, errback);
}, errback);
})(function (pairs) {
callback(pairs.reduce(function (obj, el) {
var ext = el[0].match(/[^.]*$/)[0];
var val = Filters[ext] ? Filters[ext](el[1]) : Filters.method_missing(ext, el[1]);
var name = el[0].match(/([^/]*)\.[^\/]*$/)[1];
if (typeof val === 'object') {
val.name = name;
}
obj[name] = val;
return obj;