main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | import { bind, curryN } from 'ramda';
|
---|
| 2 | import isFunction from './isFunction';
|
---|
| 3 | import ponyfill from './internal/ponyfills/Promise.allSettled';
|
---|
| 4 | export var allSettledPPonyfill = curryN(1, ponyfill);
|
---|
| 5 |
|
---|
| 6 | /**
|
---|
| 7 | * Returns a promise that is fulfilled with an array of promise state snapshots,
|
---|
| 8 | * but only after all the original promises have settled, i.e. become either fulfilled or rejected.
|
---|
| 9 | * We say that a promise is settled if it is not pending, i.e. if it is either fulfilled or rejected.
|
---|
| 10 | *
|
---|
| 11 | * @func allSettledP
|
---|
| 12 | * @memberOf RA
|
---|
| 13 | * @since {@link https://char0n.github.io/ramda-adjunct/2.18.0|v2.18.0}
|
---|
| 14 | * @category Function
|
---|
| 15 | * @typedef Settlement = { status: String, value: * }
|
---|
| 16 | * @sig [Promise a] -> Promise [Settlement a]
|
---|
| 17 | * @param {Iterable.<*>} iterable An iterable object such as an Array or String
|
---|
| 18 | * @return {Promise} Returns a promise that is fulfilled with an array of promise state snapshots
|
---|
| 19 | * @see {@link RA.allP|allP}
|
---|
| 20 | * @example
|
---|
| 21 | *
|
---|
| 22 | * RA.allSettledP([
|
---|
| 23 | * Promise.resolve(1),
|
---|
| 24 | * 2,
|
---|
| 25 | * Promise.reject(3),
|
---|
| 26 | * ]); //=> Promise([{ status: 'fulfilled', value: 1 }, { status: 'fulfilled', value: 2 }, { status: 'rejected', reason: 3 }])
|
---|
| 27 | */
|
---|
| 28 | var allSettledP = isFunction(Promise.allSettled) ? curryN(1, bind(Promise.allSettled, Promise)) : allSettledPPonyfill;
|
---|
| 29 | export default allSettledP; |
---|
Note:
See
TracBrowser
for help on using the repository browser.