Polyfill for Promise.allSettled

This commit is contained in:
mike-000
2021-09-20 11:17:59 +01:00
committed by GitHub
parent b2f1d081ed
commit b4275f887e

View File

@@ -0,0 +1,21 @@
if (typeof Promise !== 'undefined' && !Promise.allSettled && Array.from) {
Promise.allSettled =
function (promises) {
return Promise.all(
Array.from(
promises,
function (p) {
return p.then (
function (value) {
return {status: 'fulfilled', value: value};
}
).catch(
function (reason) {
return {status: 'rejected', reason: reason};
}
);
}
)
)
};
}