source: node_modules/ramda-adjunct/lib/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.7 KB
Line 
1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var _ramda = require("ramda");
6var _allP = _interopRequireDefault(require("./allP"));
7var _rejectP = _interopRequireDefault(require("./rejectP"));
8var _resolveP = _interopRequireDefault(require("./resolveP"));
9function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10/**
11 * 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.
12 * This pattern is like allP, but fulfillments and rejections are transposed - rejections become the fulfillment values and vice versa.
13 *
14 * @func noneP
15 * @memberOf RA
16 * @since {@link https://char0n.github.io/ramda-adjunct/2.22.0|v2.22.0}
17 * @category Function
18 * @sig [Promise a] -> Promise [a]
19 * @param {Iterable.<*>} iterable An iterable object such as an Array or String
20 * @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.
21 * @see {@link RA.allP|allP}
22 * @example
23 *
24 * RA.noneP([Promise.reject('hello'), Promise.reject('world')]); //=> Promise(['hello', 'world'])
25 * RA.noneP([]); //=> Promise([])
26 * RA.noneP([Promise.reject(), Promise.resolve('hello world')]); //=> Promise('hello world')
27 * RA.noneP([Promise.reject(), 'hello world']); //=> Promise('hello world')
28 */
29var noneP = (0, _ramda.curryN)(1, (0, _ramda.pipe)((0, _ramda.map)(_resolveP["default"]), (0, _ramda.map)(function (p) {
30 return p.then(_rejectP["default"], _resolveP["default"]);
31}), _allP["default"]));
32var _default = noneP;
33exports["default"] = _default;
Note: See TracBrowser for help on using the repository browser.