promise-results
Promise all results of a collection of promises whether they are resolved OR rejected.
Often we want to accomplish several asyncrounous tasks at once. Usually,
Promise.all
does what we want, but it has a couple limitations:
- Rejections only provide rejection reason. Sometimes you want the data from Promises that did resolve, or you want to know specifically which items failed and which succeeded.
- Requires a numerically indexed array.
It's often more conveniant to label our parralel jobs with object keys than a
flat index.
promise-results
will handle keyed objects or arrays.
Example
var resultsOf = ;var pack = {};packa = Promise;packb = a;packc = 42packd = { ;}; ;
allKeys
If you just want to use objects, but want to keep Promise.all
single
rejection pattern, you can use the allKeys
function instead.
Example
var allKeys = ;var pack = {};packa = Promise;packb = a;packc = 42packd = { ;}; ;
resultSet
If you like having a defined reject route, but still want access to
your partial results and rejections. You can use resultSet
.
Example
var results = ;var pack = {};packa = Promise;packb = a;packc = 42packd = { ;}; ;