risposta
Functions from caolan/async implemented using promises.
Internally risposta uses the popular Promise implementation Q
and the new faster
Promise library bluebird.
The inital code for risposta is based off this gist
by @wavdad. risposta is feature complete with async.js. For example the
implemenation of async.series
& async.parallel
by @wavdad does not support
the ability to pass in a object containing task functions as properties. This meas that
you can easily replace async with risposta.
The tests for risposta is actually the nodeunit
tests from async converted to Mocha and promisified.
Usage
Install it via;
npm install risposta
var async = require('risposta').bluebird();
async.series
async.series([
function(callback){
setTimeout(function(){
callback(null, 2);
}, 100);
},
function(callback){
setTimeout(function(){
callback(null, 'a', 'b');
}, 50)
},
function(callback){
setTimeout(function(){
callback(null, 3);
}, 110)
}
]).then(function(results){
console.log(results);
});
Most of the examples in the README.md of async
is supported by risposta. Just keep in mind that there is no optional callback you always get a promise.
For example, the example for async.times is done like so;
var createUser = function(id, callback) {
callback(null, {
id: 'user' + id
})
}
async.times(5, function(n, next){
createUser(n, function(err, user) {
next(err, user)
})
}).then(function(users) {
});
risposta : Italian - [Noun] answer, reply, response