precise-promise-all
Promise.all
is rejected if one of the elements is rejected and Promise.all fails fast: If you have four promises which resolve after a timeout, and one rejects immediately, then Promise.all rejects immediately.
from Promise All - MDN
There are some cases which Promise.all
is not applicable for:
- Not all tasks are ensured to get executed due to
fast-fail
. - You don't know the resolved values in detail, only the overall result
- You don't know rejected tasks which you may want to process afterwards.
Therefore, I made this precise-promise-all
, which will
- execute all the promise tasks
- return the precise resolved values and rejected promises as well.
Install
$ npm install --save precise-promise-all
Usage
precise-promise-all
provides two APIs which work in different way but yield the same result:
parallel(iterable)
sequential(iterable)
Example
const PrecisePromiseAll = ; // iterable is an array of `() => somethingThatCreatesAPromise()`PrecisePromiseAll;