deferrer

Deferrer is a fast promise-object generator.

npm install deferrer
4 downloads in the last day
48 downloads in the last week
103 downloads in the last month

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
npm loves you