Environment: node 8.11.x I want use async/await for sleep a while.
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)) await sleep(5000) >
You know that this right here works:
const {promisify} = require('util'); const sleep = promisify(setTimeout); ;(async () => { const ts = Date.now() await sleep(5000) console.log(Date.now()-ts) })();
This works fine, why not go with it and use it???