Skip to content
This repository has been archived by the owner on Mar 8, 2019. It is now read-only.

Latest commit

 

History

History
43 lines (27 loc) · 936 Bytes

Readme.md

File metadata and controls

43 lines (27 loc) · 936 Bytes

parallel

A simple API for running async functions in parallel.

Installation

$ component install ianstormtaylor/parallel
$ npm install ianstormtaylor/parallel

Example

var parallel = require('parallel');

function getOwner (id, callback) {
  parallel()
    .add(users.get)
    .add(organizations.get)
    .end(id, function (err, results) {
      if (err) return callback(err);
      callback(results[0] || results[1]);
    });
}

API

#add(fn, [args...])

Add a fn to be called in parallel. Optionally add args... specific to the function. Aliased to push in case you forget you aren't using batch.

#bind(context)

Pass a context for all of the functions to be bound with.

#end([args...], callback)

Run the functions in parallel and callback. Optionally pass in args... to be passed to all the functions.

License

MIT