Created
May 5, 2020 07:56
-
-
Save yurynix/c7d5d182f71bc40a8b9ca542917bcff1 to your computer and use it in GitHub Desktop.
Sleep 2 seconds
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 { promisify } = require('util'); | |
const sleep = promisify(setTimeout); | |
(async function main() { | |
await sleep(2 * 1000); | |
console.log("I'm printed after 2 seconds."); | |
}()); | |
// 1. Why we might expect that code not to work? | |
// 2. Why it actually _does_ work? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment