Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created July 30, 2011 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Raynos/1115502 to your computer and use it in GitHub Desktop.
Save Raynos/1115502 to your computer and use it in GitHub Desktop.
Flow control utility for node.js
var after = function _after(count, f) {
var c = 0, results = [];
return function _callback() {
switch (arguments.length) {
case 0: results.push(null); break;
case 1: results.push(arguments[0]); break;
default: results.push(Array.prototype.slice.call(arguments)); break;
}
if (++c === count) {
f.apply(this, results);
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment