UNPKG

726 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.allSettled = void 0;
4// Based on <https://github.com/es-shims/Promise.allSettled/blob/master/implementation.js>
5function allSettled(values) {
6 return Promise.all(values.map(item => {
7 const onFulfill = (value) => {
8 return { status: 'fulfilled', value };
9 };
10 const onReject = (reason) => {
11 return { status: 'rejected', reason };
12 };
13 const itemPromise = Promise.resolve(item);
14 try {
15 return itemPromise.then(onFulfill, onReject);
16 }
17 catch (error) {
18 return Promise.reject(error);
19 }
20 }));
21}
22exports.allSettled = allSettled;