Polyfill for Promise.allSettled
This commit is contained in:
21
examples/resources/Promise.allSettled.js
Normal file
21
examples/resources/Promise.allSettled.js
Normal 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};
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
)
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user