ramda-adjunct
Version:
Ramda Adjunct is the most popular and most comprehensive set of utilities for use with Ramda, providing a variety of useful, well tested functions with excellent documentation.
47 lines (36 loc) • 2.81 kB
JavaScript
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
exports.__esModule = true;
exports["default"] = exports.anyPPolyfill = void 0;
var _ramda = require("ramda");
var _isFunction = _interopRequireDefault(require("./isFunction"));
var _Promise = _interopRequireWildcard(require("./internal/polyfills/Promise.any"));
exports.AggregatedError = _Promise.AggregatedError;
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var anyPPolyfill = (0, _ramda.curryN)(1, _Promise["default"]);
exports.anyPPolyfill = anyPPolyfill;
/**
* Returns 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.
*
* @func anyP
* @memberOf RA
* @category Function
* @since {@link https://char0n.github.io/ramda-adjunct/2.22.0|v2.22.0}
* @sig [Promise a] -> Promise a
* @param {Iterable.<*>} iterable An iterable object such as an Array or String
* @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
* @see {@link RA.lastP|lastP}
* @example
*
* RA.anyP([
* Promise.resolve(1),
* 2,
* Promise.reject(3),
* ]); //=> Promise(1)
*/
var anyP = (0, _isFunction["default"])(Promise.any) ? (0, _ramda.curryN)(1, (0, _ramda.bind)(Promise.any, Promise)) : anyPPolyfill;
var _default = anyP;
exports["default"] = _default;
;