source: node_modules/ramda-adjunct/src/anyP.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.1 KB
Line 
1import { bind, curryN } from 'ramda';
2
3import isFunction from './isFunction';
4import ponyfill, { AggregatedError } from './internal/ponyfills/Promise.any';
5
6export const anyPPonyfill = curryN(1, ponyfill);
7export { AggregatedError };
8
9/**
10 * Returns a promise that is fulfilled by the first given promise to be fulfilled,
11 * or rejected with an array of rejection reasons if all of the given promises are rejected.
12 *
13 * @func anyP
14 * @memberOf RA
15 * @category Function
16 * @since {@link https://char0n.github.io/ramda-adjunct/2.22.0|v2.22.0}
17 * @sig [Promise a] -> Promise a
18 * @param {Iterable.<*>} iterable An iterable object such as an Array or String
19 * @return {Promise} A promise that is fulfilled by the first given promise to be fulfilled, or rejected with an array of rejection reasons if all of the given promises are rejected
20 * @see {@link RA.lastP|lastP}
21 * @example
22 *
23 * RA.anyP([
24 * Promise.resolve(1),
25 * 2,
26 * Promise.reject(3),
27 * ]); //=> Promise(1)
28 */
29const anyP = isFunction(Promise.any)
30 ? curryN(1, bind(Promise.any, Promise))
31 : anyPPonyfill;
32
33export default anyP;
Note: See TracBrowser for help on using the repository browser.