foyer
v1.2.0
Published
Parallel async functions
Downloads
13
Readme
foyer
Execute async functions in parallel and trigger a callback when done. Sets the context of the executed functions to itself.
Installation
$ npm i --save foyer
Example
var foyer = require('foyer');
foyer([
function(done) {setTimeout(function(){done('myError', 'myRes');}, 10)},
function(done) {done('myError2', 'myRes2')}
], function callback(err, res) {return res;});
// => ['myRes2', 'myRes']
API
foyer([functions], callback)
// Define an array of async functions.
var tasks = [
function(done){done(null, 'hello')},
function(done){done(null, 'world')}
];
// Define the callback to be executed
var cb = function(err, res){return res};
// Run 'Foyer' to execute your tasks and run the callback when finished
foyer(tasks, cb);
// => ['hello', 'world']