Last active
June 22, 2022 13:59
-
-
Save joao-pedrozo/3dd49dedb154293b1c8f4d1339016b2d to your computer and use it in GitHub Desktop.
Test promises
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
await Promise.all([ | |
new Promise((resolve) => setTimeout(() => {resolve('A (slow)'); console.log('A (slow)')}, 1000)), | |
new Promise((resolve) => setTimeout(() => {resolve('B (slower)'); console.log('B (slower)')}, 2000)), | |
new Promise((resolve) => setTimeout(() => {resolve('C (fast)'); console.log('C (fast)')}, 10)) | |
]) | |
const promises = Array.from({ length: 1000 }, (_, i) => i).map(item => new Promise((resolve) => setTimeout(() => { | |
resolve('A'); | |
console.log('resolved') | |
}, 3000))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment