Created
July 29, 2020 12:53
-
-
Save stekhn/95c4710356c1949b838ebbfcf138dbd5 to your computer and use it in GitHub Desktop.
Asynchronous sleep function for JavaScript, similar to Python. Also known as a wait or delay function
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 sleep(milliseconds) { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
resolve(true); | |
}, milliseconds); | |
}); | |
} | |
// await sleep(1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment