Skip to content

Instantly share code, notes, and snippets.

@scottgonzalez
Created December 20, 2011 15:56
Show Gist options
  • Save scottgonzalez/1502051 to your computer and use it in GitHub Desktop.
Save scottgonzalez/1502051 to your computer and use it in GitHub Desktop.
var getFiles = Step.fn(
function readDir(dir) {
this.keep(dir);
fs.readdir(dir, this.parallel());
},
function readFiles(err, dir, results) {
if (err) throw err;
// Create a new group
var group = this.group();
results.forEach(function (filename) {
if (/\.js$/.test(filename)) {
fs.readFile(dir + "/" + filename, 'utf8', group());
}
});
}
);
getFiles(__dirname, function(err , files) {
if (err) throw err;
console.dir(files);
});
@scottgonzalez
Copy link
Author

Merging this and this.parallel() would be fantastic. The fact that you'd have to use this.parallel() when using this.keep() was a concern of mine, since it'd be a potential pitfall for users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment