Skip to content

Instantly share code, notes, and snippets.

@mischah

mischah/delay.js

Created Apr 14, 2019
Embed
What would you like to do?
Promisified setTimeout
// Promisified setTimeout
const delay = (duration = 0) =>
new Promise(resolve =>
setTimeout(() => {
resolve();
}, duration)
);
// Usage
async function myFunction() {
console.log('Do something');
await delay();
console.log('Do something else');
}
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.