Last Updated: February 25, 2016
· tralamazza

Playing with

Async .auto() can save you from writing a forest of .series() and .parallel(). If you want to reuse existing series/parallels callbacks, or just look silly, you can try the following hack:

function aapply(deps, fn) {
  deps = [].concat(deps);
  return deps.concat(function (next, hash) {
    var args = (i) { return hash[i]; });
    fn.apply(null, args.concat(next));

An example should be enough :){
  foo: function (next) { next(null, 'foo'); },
  bar: function (next) { next(null, 'man'); },
  wat: aapply(['foo', 'bar'], function (a, b, next) {
    next(null, a + b + 'xu');
}, console.log);

edited for reduced overall readability and making sure deps is an array.