[d24f17c] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | exports.__esModule = true;
|
---|
| 4 | exports["default"] = exports.allSettledPPonyfill = void 0;
|
---|
| 5 | var _ramda = require("ramda");
|
---|
| 6 | var _isFunction = _interopRequireDefault(require("./isFunction"));
|
---|
| 7 | var _Promise = _interopRequireDefault(require("./internal/ponyfills/Promise.allSettled"));
|
---|
| 8 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
---|
| 9 | var allSettledPPonyfill = (0, _ramda.curryN)(1, _Promise["default"]);
|
---|
| 10 |
|
---|
| 11 | /**
|
---|
| 12 | * Returns a promise that is fulfilled with an array of promise state snapshots,
|
---|
| 13 | * but only after all the original promises have settled, i.e. become either fulfilled or rejected.
|
---|
| 14 | * We say that a promise is settled if it is not pending, i.e. if it is either fulfilled or rejected.
|
---|
| 15 | *
|
---|
| 16 | * @func allSettledP
|
---|
| 17 | * @memberOf RA
|
---|
| 18 | * @since {@link https://char0n.github.io/ramda-adjunct/2.18.0|v2.18.0}
|
---|
| 19 | * @category Function
|
---|
| 20 | * @typedef Settlement = { status: String, value: * }
|
---|
| 21 | * @sig [Promise a] -> Promise [Settlement a]
|
---|
| 22 | * @param {Iterable.<*>} iterable An iterable object such as an Array or String
|
---|
| 23 | * @return {Promise} Returns a promise that is fulfilled with an array of promise state snapshots
|
---|
| 24 | * @see {@link RA.allP|allP}
|
---|
| 25 | * @example
|
---|
| 26 | *
|
---|
| 27 | * RA.allSettledP([
|
---|
| 28 | * Promise.resolve(1),
|
---|
| 29 | * 2,
|
---|
| 30 | * Promise.reject(3),
|
---|
| 31 | * ]); //=> Promise([{ status: 'fulfilled', value: 1 }, { status: 'fulfilled', value: 2 }, { status: 'rejected', reason: 3 }])
|
---|
| 32 | */
|
---|
| 33 | exports.allSettledPPonyfill = allSettledPPonyfill;
|
---|
| 34 | var allSettledP = (0, _isFunction["default"])(Promise.allSettled) ? (0, _ramda.curryN)(1, (0, _ramda.bind)(Promise.allSettled, Promise)) : allSettledPPonyfill;
|
---|
| 35 | var _default = allSettledP;
|
---|
| 36 | exports["default"] = _default; |
---|