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
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
Actually, this isn't a bad idea. Also we can maybe merge
thisandthis.parallel()since they do the same thing in the single case. People are constantly confused by the difference between this.parallel() and this.group(). Having one less API point may help the confusion.