Created
September 10, 2018 20:47
-
-
Save danillouz/79999fea5d7f93a79d9b6dd83fe623e6 to your computer and use it in GitHub Desktop.
Timeout routine.
This file contains 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
'use strict'; | |
function timeout(ms) { | |
console.log('timeout start'); | |
return new Promise(resolve => { | |
setTimeout(() => { | |
console.log(`timeout cb fired after ${ms} ms`); | |
resolve(); | |
}, ms); | |
}); | |
} | |
async function main() { | |
console.log('main start'); | |
timeout(5e3); | |
console.log('main end'); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment