Remove Promise allSettled polyfill as its widespread enough now and js-sdk uses it directly
This commit is contained in:
parent
97c6ee39d0
commit
17bbbff479
4 changed files with 5 additions and 25 deletions
|
@ -51,24 +51,6 @@ export function defer<T>(): IDeferred<T> {
|
|||
return {resolve, reject, promise};
|
||||
}
|
||||
|
||||
// Promise.allSettled polyfill until browser support is stable in Firefox
|
||||
export function allSettled<T>(promises: Promise<T>[]): Promise<Array<ISettledFulfilled<T> | ISettledRejected>> {
|
||||
if (Promise.allSettled) {
|
||||
return Promise.allSettled<T>(promises);
|
||||
}
|
||||
|
||||
// @ts-ignore - typescript isn't smart enough to see the disjoint here
|
||||
return Promise.all(promises.map((promise) => {
|
||||
return promise.then(value => ({
|
||||
status: "fulfilled",
|
||||
value,
|
||||
})).catch(reason => ({
|
||||
status: "rejected",
|
||||
reason,
|
||||
}));
|
||||
}));
|
||||
}
|
||||
|
||||
// Helper method to retry a Promise a given number of times or until a predicate fails
|
||||
export async function retry<T, E extends Error>(fn: () => Promise<T>, num: number, predicate?: (e: E) => boolean) {
|
||||
let lastErr: E;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue