foreach-in-dir

1.2.1 • Public • Published

Run a function on each file in a directory

NPM Version NPM Downloads Build Status js-happiness-style

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) {
    // ...
});

Readme

Keywords

Package Sidebar

Install

npm i foreach-in-dir

Weekly Downloads

4

Version

1.2.1

License

ISC

Last publish

Collaborators

  • wesleytodd