source: node_modules/ramda-adjunct/lib/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: 2.9 KB
Line 
1"use strict";
2
3function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4exports.__esModule = true;
5exports["default"] = exports.anyPPonyfill = void 0;
6var _ramda = require("ramda");
7var _isFunction = _interopRequireDefault(require("./isFunction"));
8var _Promise = _interopRequireWildcard(require("./internal/ponyfills/Promise.any"));
9exports.AggregatedError = _Promise.AggregatedError;
10function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13var anyPPonyfill = (0, _ramda.curryN)(1, _Promise["default"]);
14exports.anyPPonyfill = anyPPonyfill;
15/**
16 * Returns a promise that is fulfilled by the first given promise to be fulfilled,
17 * or rejected with an array of rejection reasons if all of the given promises are rejected.
18 *
19 * @func anyP
20 * @memberOf RA
21 * @category Function
22 * @since {@link https://char0n.github.io/ramda-adjunct/2.22.0|v2.22.0}
23 * @sig [Promise a] -> Promise a
24 * @param {Iterable.<*>} iterable An iterable object such as an Array or String
25 * @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
26 * @see {@link RA.lastP|lastP}
27 * @example
28 *
29 * RA.anyP([
30 * Promise.resolve(1),
31 * 2,
32 * Promise.reject(3),
33 * ]); //=> Promise(1)
34 */
35var anyP = (0, _isFunction["default"])(Promise.any) ? (0, _ramda.curryN)(1, (0, _ramda.bind)(Promise.any, Promise)) : anyPPonyfill;
36var _default = anyP;
37exports["default"] = _default;
Note: See TracBrowser for help on using the repository browser.