source: node_modules/ramda-adjunct/src/allSettledP.js

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
Line 
1import { bind, curryN } from 'ramda';
2
3import isFunction from './isFunction';
4import ponyfill from './internal/ponyfills/Promise.allSettled';
5
6export const allSettledPPonyfill = curryN(1, ponyfill);
7
8/**
9 * Returns a promise that is fulfilled with an array of promise state snapshots,
10 * but only after all the original promises have settled, i.e. become either fulfilled or rejected.
11 * We say that a promise is settled if it is not pending, i.e. if it is either fulfilled or rejected.
12 *
13 * @func allSettledP
14 * @memberOf RA
15 * @since {@link https://char0n.github.io/ramda-adjunct/2.18.0|v2.18.0}
16 * @category Function
17 * @typedef Settlement = { status: String, value: * }
18 * @sig [Promise a] -> Promise [Settlement a]
19 * @param {Iterable.<*>} iterable An iterable object such as an Array or String
20 * @return {Promise} Returns a promise that is fulfilled with an array of promise state snapshots
21 * @see {@link RA.allP|allP}
22 * @example
23 *
24 * RA.allSettledP([
25 * Promise.resolve(1),
26 * 2,
27 * Promise.reject(3),
28 * ]); //=> Promise([{ status: 'fulfilled', value: 1 }, { status: 'fulfilled', value: 2 }, { status: 'rejected', reason: 3 }])
29 */
30const allSettledP = isFunction(Promise.allSettled)
31 ? curryN(1, bind(Promise.allSettled, Promise))
32 : allSettledPPonyfill;
33
34export default allSettledP;
Note: See TracBrowser for help on using the repository browser.