Iterate over the files of a directory
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
eachfile.js
package.json

README.md

eachfile

Iterate the files of a directory.

var eachfile = require("eachfile");

eachfile.in('.', function(stats, next){
    console.log(stats.name, stats.isFile());
    next();
});

Used with the eachline module:

var eachfile = require("eachfile");
var eachline = require("eachline");

eachfile.in('./data/', function(stats, next){

    process.stdout.write(stats.fullpath);

    eachline.in(stats.fullpath, function(line, i){
        if(!line) return;
        //do something
    })
    .on('finish', function () {
        console.log(' ..done');
        next();
    });

})
.on('error', function (err) {
    console.trace(err)
});

Install

npm install eachfile

license

MIT