Merge pull request #12785 from mike-000/Promise.allSettled

Promise.allSettled polyfill and other browser compatibilty
This commit is contained in:
Tim Schaub
2021-09-24 19:32:53 +00:00
committed by GitHub
5 changed files with 35 additions and 7 deletions
+21
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};
}
);
}
)
)
};
}