Skip to content

Instantly share code, notes, and snippets.

@alessioalex
Created November 22, 2014 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alessioalex/56212d843310cd560e42 to your computer and use it in GitHub Desktop.
Save alessioalex/56212d843310cd560e42 to your computer and use it in GitHub Desktop.
simple-parallel-control-flow.js
// 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