gather

Defer function execution until all its arguments are ready

gather

Control flow utility that runs a callback after all the dependencies are (asynchronously) met. Useful when a function depends on some resources that are obtained asynchronously and independently.

var done = gather(function (ab) {
  console.log(+ b);
});
 
async(function () {
  async(function () {
    done('foo', );
  });
});
 
async(function () {
  done(, 'bar');
});
 
// Prints "foobar". 

Returns a function that can feed results to done.

Pass arguments as they become ready, interleaving with for not-yet-resolved ones. The order and total count matter.

Once all the arguments are supplied, done is finally called.

npm install gather

MIT