Created
November 22, 2014 13:47
-
-
Save alessioalex/56212d843310cd560e42 to your computer and use it in GitHub Desktop.
simple-parallel-control-flow.js
This file contains 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
// simplest control flow function ever for async parallel functions | |
var doParallel = function(counter, cb) { | |
return function() { | |
// counter reached 0 | |
if (!--counter) { | |
cb(); | |
} | |
}; | |
}; | |
var next = doParallel(5, function() { console.log('ok'); }); | |
next(); | |
next(); | |
next(); | |
next(); | |
next(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment