Skip to content

Instantly share code, notes, and snippets.

@ShivamJoker
Created October 14, 2022 12:56
Show Gist options
  • Save ShivamJoker/dafe821cae2ff8076eaf132b45f744aa to your computer and use it in GitHub Desktop.
Save ShivamJoker/dafe821cae2ff8076eaf132b45f744aa to your computer and use it in GitHub Desktop.
Simple JavaScript promise based function to add delay between your executions
const sleep = (duration) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, duration);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment