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

ianstormtaylor/parallel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A simple API for running async functions in parallel.

Resources

Stars

Watchers

Forks

Packages

No packages published