Created
October 11, 2014 09:49
-
-
Save bekzod/f29ef8ce23cf5e0d9cf8 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 async = require('async'); | |
| function someFunc(i, callback){ | |
| function cbWrapper(){ | |
| callback(null, i); | |
| } | |
| i % 2 == 0 ? cbWrapper() : setTimeout(cbWrapper, 100); | |
| } | |
| var jobs = []; | |
| for (var t = 0; t < 10; t++) { | |
| jobs.push( someFunc.bind(someFunc, t ) ); | |
| } | |
| async.parallel([ | |
| function(callback){ | |
| async.parallel(jobs,callback); | |
| } | |
| ], function(err,res){ | |
| console.log(res); | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment