Skip to content

Instantly share code, notes, and snippets.

@dimroc
Last active November 12, 2018 21:10
Show Gist options
  • Save dimroc/ec6a7f402891bf7ba1cd28504946fad2 to your computer and use it in GitHub Desktop.
Save dimroc/ec6a7f402891bf7ba1cd28504946fad2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
const countdown = async () => {
await delay(5000)
console.log("hello world")
}
countdown()
console.log("bye world. Although out of order, notice how application does not exit until final await.")
@dimroc
Copy link
Author

dimroc commented Nov 12, 2018

Output:

$ node blockingAwait.js
bye world. Although out of order, notice how application does not exit until final await.
hello world

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment