source: node_modules/ramda-adjunct/es/noneP.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 { curryN, map, pipe } from 'ramda';
2import allP from './allP';
3import rejectP from './rejectP';
4import resolveP from './resolveP';
5
6/**
7 * Returns a Promise that is resolved with an array of reasons when all of the provided Promises reject, or rejected when any Promise is resolved.
8 * This pattern is like allP, but fulfillments and rejections are transposed - rejections become the fulfillment values and vice versa.
9 *
10 * @func noneP
11 * @memberOf RA
12 * @since {@link https://char0n.github.io/ramda-adjunct/2.22.0|v2.22.0}
13 * @category Function
14 * @sig [Promise a] -> Promise [a]
15 * @param {Iterable.<*>} iterable An iterable object such as an Array or String
16 * @return {Promise} A Promise that is resolved with a list of rejection reasons if all Promises are rejected, or a Promise that is rejected with the fulfillment value of the first Promise that resolves.
17 * @see {@link RA.allP|allP}
18 * @example
19 *
20 * RA.noneP([Promise.reject('hello'), Promise.reject('world')]); //=> Promise(['hello', 'world'])
21 * RA.noneP([]); //=> Promise([])
22 * RA.noneP([Promise.reject(), Promise.resolve('hello world')]); //=> Promise('hello world')
23 * RA.noneP([Promise.reject(), 'hello world']); //=> Promise('hello world')
24 */
25var noneP = curryN(1, pipe(map(resolveP), map(function (p) {
26 return p.then(rejectP, resolveP);
27}), allP));
28export default noneP;
Note: See TracBrowser for help on using the repository browser.