Created
December 10, 2019 11:13
-
-
Save mrk21/60948fd3872e7ef82ceb9c2d0e30c10e to your computer and use it in GitHub Desktop.
Sleep for JavaScript (>= ES2015)
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
const sleep = (msec) => new Promise(resolve => setTimeout(resolve, msec)); | |
const main = async () => { | |
console.log(1); | |
await sleep(1000); | |
console.log(2); | |
await sleep(1000); | |
console.log(3); | |
await sleep(1000); | |
}; | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment