Last active
June 2, 2018 10:45
-
-
Save slikts/6029477fe2c3215b9bc49510f30a434a to your computer and use it in GitHub Desktop.
Promise.settle()
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
const settle = ps => | |
Promise.all( | |
ps.map(async p => { | |
let [value, error, ok] = [null, null, false]; | |
try { | |
value = await p; | |
ok = true; | |
} catch (e) { | |
error = e; | |
} | |
return { value, error, ok }; | |
}), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment