UNPKG

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.

43 lines (35 loc) 1.76 kB
"use strict"; exports.__esModule = true; exports["default"] = exports.allSettledPPolyfill = void 0; var _ramda = require("ramda"); var _curry = _interopRequireDefault(require("ramda/src/internal/_curry1")); var _isFunction = _interopRequireDefault(require("./isFunction")); var _Promise = _interopRequireDefault(require("./internal/polyfills/Promise.allSettled")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } var allSettledPPolyfill = (0, _curry["default"])(_Promise["default"]); /** * Returns a promise that is fulfilled with an array of promise state snapshots, * but only after all the original promises have settled, i.e. become either fulfilled or rejected. * We say that a promise is settled if it is not pending, i.e. if it is either fulfilled or rejected. * * @func allSettledP * @memberOf RA * @since {@link https://char0n.github.io/ramda-adjunct/2.18.0|v2.18.0} * @category Function * @typedef Settlement = { status: String, value: * } * @sig [Promise a] -> Promise [Settlement a] * @param {Iterable.<*>} iterable An iterable object such as an Array or String * @return {Promise} Returns a promise that is fulfilled with an array of promise state snapshots * @see {@link RA.allP|allP} * @example * * RA.allSettledP([ * Promise.resolve(1), * 2, * Promise.reject(3), * ]); //=> Promise([{ status: 'fulfilled', value: 1 }, { status: 'fulfilled', value: 2 }, { status: 'rejected', reason: 3 }]) */ exports.allSettledPPolyfill = allSettledPPolyfill; var allSettledP = (0, _isFunction["default"])(Promise.allSettled) ? (0, _curry["default"])((0, _ramda.bind)(Promise.allSettled, Promise)) : allSettledPPolyfill; var _default = allSettledP; exports["default"] = _default;