Created
March 10, 2021 05:26
-
-
Save snsinfu/38bd2081b331ada7733e2b2dda7454c0 to your computer and use it in GitHub Desktop.
Typescript async sleep
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
function asleep(delay: number): Promise<void> { | |
return new Promise<void>((resolve, reject) => setTimeout(resolve, delay)); | |
} | |
console.log(Date.now()); | |
await asleep(100); | |
console.log(Date.now()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment