caolan/async — pull request #109 by bcherry (2012-02-29 08:02:33+00:00)
Title: Allow nested arrays in waterfall

Hey there!

This is a pretty simple enhancement to waterfall, which flattens the tasks array prior to running the tasks. In practice, this means you can now pass sub-arrays of tasks in. This is handy because it allows you to create reusable tasks that can be included in waterfall workflows, where tasks can be waterfalls themselves.

For example:

function foo(done) {
console.log('foo');
}

function bar(done) {
console.log('bar');
}

function baz(done) {
console.log('baz');
}

var foobar = [foo, bar];

async.waterfall([
foobar,
baz
]);

// logs foo, bar, baz

What do you think?

(this is inspired by Connect middleware's similar behavior)