Created
March 24, 2017 17:29
-
-
Save neonerd/92da153fdc4bfbc814872c0a82e48ce3 to your computer and use it in GitHub Desktop.
Async / await wait
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 wait (s) { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => resolve(true), s) | |
}) | |
} | |
async function main () { | |
console.log('start now') | |
await wait(2000) | |
console.log('end after 2 seconds') | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment