Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ asynchronous: they get a "callback" argument and should invoke it as
`callback(err, result)`. The error and result will be saved and made available
to the original caller when all of these functions complete.

If `args` is an array, it will be used as the `funcs` property for convenience.

This function returns the same "result" object it passes to the callback, and
you can use the fields in this object to debug or observe progress:

Expand Down Expand Up @@ -185,6 +187,8 @@ The named arguments (that go inside `args`) are:
* `funcs`: input functions, to be invoked in series
* `arg`: arbitrary argument that will be passed to each function

If `args` is an array, it will be used as the `funcs` property for convenience.

The functions are invoked in order as `func(arg, callback)`, where "arg" is the
user-supplied argument from "args" and "callback" should be invoked in the usual
way. If any function emits an error, the whole pipeline stops.
Expand Down
6 changes: 6 additions & 0 deletions lib/vasync.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ function parallel(args, callback)
{
var funcs, rv, doneOne, i;

if (Array.isArray(args))
args = {funcs: args};

mod_assert.equal(typeof (args), 'object', '"args" must be an object');
mod_assert.ok(Array.isArray(args['funcs']),
'"args.funcs" must be specified and must be an array');
Expand Down Expand Up @@ -151,6 +154,9 @@ function pipeline(args, callback)
{
var funcs, uarg, rv, next;

if (Array.isArray(args))
args = {funcs: args};

mod_assert.equal(typeof (args), 'object', '"args" must be an object');
mod_assert.ok(Array.isArray(args['funcs']),
'"args.funcs" must be specified and must be an array');
Expand Down