main
Last change
on this file since 65b6638 was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | import { bind, curryN } from 'ramda';
|
---|
| 2 |
|
---|
| 3 | import isFunction from './isFunction';
|
---|
| 4 | import ponyfill, { AggregatedError } from './internal/ponyfills/Promise.any';
|
---|
| 5 |
|
---|
| 6 | export const anyPPonyfill = curryN(1, ponyfill);
|
---|
| 7 | export { 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 | */
|
---|
| 29 | const anyP = isFunction(Promise.any)
|
---|
| 30 | ? curryN(1, bind(Promise.any, Promise))
|
---|
| 31 | : anyPPonyfill;
|
---|
| 32 |
|
---|
| 33 | export default anyP;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.