Skip to content

Instantly share code, notes, and snippets.

@Nithanaroy
Created January 5, 2020 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nithanaroy/f0264c6bed46a8793ee3b744b5dfcd22 to your computer and use it in GitHub Desktop.
Save Nithanaroy/f0264c6bed46a8793ee3b744b5dfcd22 to your computer and use it in GitHub Desktop.
Snippet that achieves Python's sleep
async function main() {
console.log(`Start: ${performance.now()}`);
await sleep(2000);
console.log(`End: ${performance.now()}`);
}
function sleep(timeInMs) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve("Time up!");
}, timeInMs);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment