1.0.1 • Published 8 years ago
promise-buffer v1.0.1
promise-buffer
Buffers promises and run them in order on the next tick
Installation
promise-buffer can be installed using
$ npm install --save promise-buffer
Usage
var buffer = require('promise-buffer').promiseBuffer()
class Abc {
foo () {
buffer.push(() => {
console.log('foo')
})
return this
}
bar () {
buffer.push(() => {
return new Promise(function (resolve, reject) {
setTimeout(function () {
console.log('bar')
resolve()
}, 1000)
})
})
return this
}
}
var abc = new Abc()
abc.foo().bar().foo()
// foo
// bar
// foo