PromiseUtils
Some useful functions for promises
Install :
npm install @chymz/promise-utils
Progress callback
When you call all()
, props()
, series()
or seriesProps()
returned promise
have an available progress()
method to listen progress of promises executions
Usage :
import PromiseUtils from '@chymz/promise-utils';
PromiseUtils.all([
promise(),
promise(),
promise()
])
.progress((current, total) => {
let percent = current / total * 100;
})
.then(results => {
})
props()
Instead of using an array with Promise.all()
you can pass an object to
PromiseUtils.props()
Usage :
import PromiseUtils from '@chymz/promise-utils';
PromiseUtils.props({
one: promise(),
two: promise()
})
.then(results => {
})
series()
@todo : description (see tests/index.js
)
seriesProps()
@todo : description (see tests/index.js
)
Override Promise class used by this lib
If you don't want to use native Promise class, you can do this :
import Bluebird from 'bluebird';
import PromiseUtils from 'promise-utils';
PromiseUtils.Promise = Bluebird;
global.Promise = Bluebird;
Todo
- Polyfill note for IE11 & Old browsers
series()
& seriesProps()
description/samples
License
See LICENSE
file