Skip to content

Instantly share code, notes, and snippets.

View Orion98MC's full-sized avatar

Thierry Passeron Orion98MC

View GitHub Profile
function whenDone(callback) {
var left = 0
, done = function() { if (--left === 0) { callback(); } };
return function doThis(work, n) {
if (typeof n !== 'undefined') left += n;
else left++;
process.nextTick(function(){ work(done); });
};
}