Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/douglasduteil/promise-buffer
Buffers promises and run them in order on the next tick
https://github.com/douglasduteil/promise-buffer
Last synced: about 1 month ago
JSON representation
Buffers promises and run them in order on the next tick
- Host: GitHub
- URL: https://github.com/douglasduteil/promise-buffer
- Owner: douglasduteil
- License: wtfpl
- Created: 2016-04-24T16:40:46.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-23T15:29:10.000Z (almost 7 years ago)
- Last Synced: 2024-11-06T18:18:33.178Z (about 2 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# promise-buffer [![Build Status][travis-image]][travis-url] [![NPM version][npm-image]][npm-url] [![No Maintenance Intended][unmaintained-image]][unmaintained-url]
> Buffers promises and run them in order on the next tick
## Installation
promise-buffer can be installed using
```sh
$ npm install --save promise-buffer
```## Usage
```js
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
```[npm-url]: https://npmjs.org/package/promise-buffer
[npm-image]: http://img.shields.io/npm/v/promise-buffer.svg
[travis-url]: http://travis-ci.org/douglasduteil/promise-buffer
[travis-image]: http://travis-ci.org/douglasduteil/promise-buffer.svg?branch=master
[unmaintained-image]: http://unmaintained.tech/badge.svg
[unmaintained-url]: http://unmaintained.tech