Skip to content

Instantly share code, notes, and snippets.

@evonsdesigns
Created September 6, 2018 20:07
Show Gist options
  • Save evonsdesigns/e499d43189242e88bb29c4e23a7998f2 to your computer and use it in GitHub Desktop.
Save evonsdesigns/e499d43189242e88bb29c4e23a7998f2 to your computer and use it in GitHub Desktop.
const timeout = ms => new Promise(res => setTimeout(res, ms))
function convinceMe (convince) {
let unixTime = new Date().getTime()
console.log(`Delay ${convince} at ${unixTime}`)
return unixTime
}
async function delay () {
let start = convinceMe('started')
await timeout(5501)
let end = convinceMe('finished')
console.log('Diff:', end - start)
}
delay()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment