Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexdriaguine/trainflow
https://github.com/alexdriaguine/trainflow
promise sequence
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/alexdriaguine/trainflow
- Owner: alexdriaguine
- License: mit
- Created: 2017-05-06T10:25:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-17T05:15:32.000Z (over 7 years ago)
- Last Synced: 2024-12-10T04:56:07.977Z (28 days ago)
- Topics: promise, sequence
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/trainflow
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# trainflow
A tool to make sure a promise in a sequence is resolved before moving on to the next one## Usage
```bash
yarn add trainflow # or good ol npm
``````javascript
const promiseSequence = require('./index')const getPromiseFnThatResolves = (val) =>
() =>
new Promise((resolve, reject) => {
setTimeout(() => {
resolve(val)
}, val * 1000)
})const promiseFns = [
getPromiseFnThatResolves(2),
getPromiseFnThatResolves(4),
getPromiseFnThatResolves(0),
getPromiseFnThatResolves(1),
getPromiseFnThatResolves(5),
getPromiseFnThatResolves(3)
]promiseSequence({
promiseFns,
ignoreErrors: true, // optional
onResolveCurrent: val => console.log(val) // optional
})```
See tests for more usage