Last active
January 26, 2020 13:30
-
-
Save nim4n136/7ac9e59347d280dafb3e6d0dfcbff1c9 to your computer and use it in GitHub Desktop.
create function sleep nodejs with async await
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 sleep = require('util').promisify(setTimeout) | |
| let doSometing = async () => { | |
| console.log("start") | |
| await sleep(3000) | |
| console.log("end") | |
| } | |
| doSometing() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment