Skip to content

Instantly share code, notes, and snippets.

@nandomoreirame
Created March 31, 2020 20:46
Show Gist options
  • Save nandomoreirame/3675e47e5a1674987acb1ce245f8b224 to your computer and use it in GitHub Desktop.
Save nandomoreirame/3675e47e5a1674987acb1ce245f8b224 to your computer and use it in GitHub Desktop.
Timeout with Promise for use async await
const timeout = ms => new Promise(resolve => setTimeout(resolve, ms));
const sleep = async (fn, ...args) => {
await timeout(3000);
return fn(...args);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment