1.0.1 • Published 8 years ago

promise-buffer v1.0.1

Weekly downloads
2
License
WTFPL
Repository
github
Last release
8 years ago

promise-buffer Build Status NPM version No Maintenance Intended

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