Created
July 19, 2022 11:52
-
-
Save szaranger/f0952907edd6697a3e302fbd468816bb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| async function run() { | |
| const settledPromises = Promise.allSettled([ | |
| new Promise((resolve) => setTimeout(() => resolve(["shirts", "trousers"]), 800)), | |
| new Promise((resolve) => setTimeout(() => resolve(["sneakers", "boots"]), 800)), | |
| ]); | |
| // wait... | |
| const promises = await settledPromises; | |
| // after 0.8 seconds | |
| console.log(promises); | |
| /* | |
| [[object Object] { | |
| status: "fulfilled", | |
| value: ["shirts", "trousers"] | |
| }, [object Object] { | |
| status: "fulfilled", | |
| value: ["sneakers", "boots"] | |
| }] | |
| */ | |
| } | |
| run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment