foreach-in-dir
v1.2.1
Published
Run a function for each file in a directory
Downloads
15
Readme
Run a function on each file in a directory
Runs an asyncronous function on each file in a directory in parallel.
Usage
$ npm install --save foreach-in-dir
var forEachInDir = require('foreach-in-dir');
var path = require('path');
var fs = require('fs');
var dir = './dir';
forEachInDir(dir, function (filename, done) {
// do something with file
fs.readfile(path.join(dir, filename, done);
}, function (err, results) {
if (err) {
return throw err;
}
// results is an array of the contents of each file
});
// Also has a recursive method
forEachInDir.recursive(dir, function (filename, done) {
// ...
});