Asynchronous execution library
Run asynchronous methods sequentially or in parallel.
Multi provides a mechanism to run callbacks asynchronously in sequence, or in parallel.
Execution can be interrupted if there is an error. After all callbacks have finished executing, the library will provide [err, results], containing the errors (null if none) and the respective results of the callbacks.
To install multi:
npm install multi
To install multi's dependencies:
You can also install the dependencies with
To run the test suites:
Multi works with objects that have asynchronous methods. It creates a wrapper with the same methods as the original, which can be run either in sequence or in parallel.
The following example wraps the
fs module in a Multi object, and performs some operations:
var fs = require'fs'Multi = require'multi';var mfs = fs;mfsreadFile'./assets/hello.html' 'utf-8';mfsreaddir'./assets/';mfsreadFile'./assets/style.css' 'utf-8';mfslstat'./assets/text.txt';mfsexecconsole.logerr results;;
There are several examples provided on the various uses of Multi, available in the
The following options are accepted in the Multi configuration object (second parameter of constructor):
parallel: Determines if the methods will run in parallel. Defaults to
interrupt: Interrupts execution if an error is encountered. Defaults to
Copyright © 2012, Ernesto Méndez. (MIT License)
See LICENSE for more info.