-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a98a6c1
commit 684419d
Showing
2 changed files
with
33 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
// Pollyfill for Promise.allSettled() | ||
// Promise.allSettled() takes an iterable of promises and returns a single promise that is fulfilled with an array of promise settlement result | ||
|
||
let allSettledPolyfill = (arr: array<promise<unit>>) => { | ||
let allSettledPolyfill = (arr: array<promise<Js.Json.t>>) => { | ||
let res = arr->Array.map(promise => | ||
promise->Promise.then(val => { | ||
promise | ||
->Promise.then(val => { | ||
Promise.resolve(val) | ||
}) | ||
->Promise.catch(_err => { | ||
Js.Json.null->Js.Promise.resolve | ||
}) | ||
) | ||
Promise.all(res) | ||
} |