Created
December 20, 2011 15:56
-
-
Save scottgonzalez/1502051 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Merging
thisandthis.parallel()would be fantastic. The fact that you'd have to usethis.parallel()when usingthis.keep()was a concern of mine, since it'd be a potential pitfall for users.