@cfware/cleanable-interval
A variant of setInterval that returns a cleanup function.
Usage
import cleanableInterval from '@cfware/cleanable-interval';
let iter = 0;
const cleanupFn = cleanableInterval(() => {
iter++;
console.log(`Iteration ${iter} of 2`);
if (iter > 1) {
cleanupFn();
}
}, 100);