Skip to content

Instantly share code, notes, and snippets.

@danillouz
Created September 10, 2018 20:47
Show Gist options
  • Save danillouz/79999fea5d7f93a79d9b6dd83fe623e6 to your computer and use it in GitHub Desktop.
Save danillouz/79999fea5d7f93a79d9b6dd83fe623e6 to your computer and use it in GitHub Desktop.
Timeout routine.
'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