Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A delay function that can be used with async-await
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
// Sample code using `delay`
const test = async () => {
const time = () => console.log((new Date).toLocaleTimeString());
time();
await delay(1000);
time();
await delay(3000);
time();
};
test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.