Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

deferrer

1.1.0 • Public • Published

deferrer NPM version Build Status Dependency Status

Deferrer is a fast promise-object generator.

Exmaples

function Foo (){}
 
Foo.prototype._a = function (args, done) {
    setTimeout(function (){
        console.log('a', args);
        done(null);
    
    }, 100);
}
 
Foo.prototype._b = function (args, done) {
    process.nextTick(function(){
        console.log('b', args);
        done(null);
    });
}
 
Foo.prototype._done = function(err, callback){
    callback(err);
}
 
var deferrer = require('deferrer');
 
deferrer({
    host: Foo.prototype
    type: 'parallel'
})
.promise('a', '_a')
.promise('b', '_b')
.done('_done');
 
var foo = new Foo();
 
foo.a(1, 2).b(3, 4).done(function(err){
    console.log('done');
});
 
// b [3, 4]
// a [1, 3]
// done

Keywords

none

Install

npm i deferrer

DownloadsWeekly Downloads

3

Version

1.1.0

License

none

Last publish

Collaborators

  • avatar