Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
slow down interval execution in javascript
const slowDownInterval = (ms, limit=10) => {
_slowDownInterval(ms, limit, 0);
}
const _slowDownInterval = (ms, limit, counter) => {
const sleepTimme = ms + (counter * 100);
if (limit > counter) {
setTimeout(() => {
console.log(`Interval: count => ${counter} ...`);
_slowDownInterval(ms, limit, counter + 1);
}, sleepTimme);
}
}
slowDownInterval(500, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment