Skip to content

Instantly share code, notes, and snippets.

@DannyFeliz
Last active August 4, 2018 03:43
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 DannyFeliz/6b1a4ad3bc57b0cfb1c278aa8ba49dcc to your computer and use it in GitHub Desktop.
Save DannyFeliz/6b1a4ad3bc57b0cfb1c278aa8ba49dcc to your computer and use it in GitHub Desktop.
for loop with timeout
const timeoutList = [5000, 2500, 4500];
async function initInterval() {
for(const timeout of timeoutList) {
await runTimeout(timeout);
}
}
function runTimeout(timeout) {
return new Promise(resolve => {
setTimeout(() => {
console.log("Run =>", timeout);
resolve();
}, timeout);
});
}
initInterval();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment