Replace bluebird specific promise things. Fix uses of sync promise code.
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
5c24547ef5
commit
54dcaf1302
6 changed files with 53 additions and 38 deletions
|
@ -47,3 +47,20 @@ export function defer(): {resolve: () => {}, reject: () => {}, promise: Promise}
|
|||
|
||||
return {resolve, reject, promise};
|
||||
}
|
||||
|
||||
// Promise.allSettled polyfill until browser support is stable in Firefox
|
||||
export function allSettled(promises: Promise[]): {status: string, value?: any, reason?: any}[] {
|
||||
if (Promise.allSettled) {
|
||||
return Promise.allSettled(promises);
|
||||
}
|
||||
|
||||
return Promise.all(promises.map((promise) => {
|
||||
return promise.then(value => ({
|
||||
status: "fulfilled",
|
||||
value,
|
||||
})).catch(reason => ({
|
||||
status: "rejected",
|
||||
reason,
|
||||
}));
|
||||
}));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue