Created
May 10, 2024 12:16
-
-
Save jsmrcaga/b3a5ca63b7f67da0561b8e723ed8733f 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
// Tested on node 18 | |
// The result is sequential | |
function rand_promise(i) { | |
return new Promise((r) => { | |
const timeout = Math.random() * 1000; | |
setTimeout(() => r(i), timeout); | |
}); | |
} | |
const max = 15; | |
async function run() { | |
for(let i = 0; i < max; i++) { | |
const result = await rand_promise(i); | |
console.log('CURRENT RESULT', i); | |
} | |
} | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment