Returns true for every _n_th call, eg 2 for every second call.
If nth is 1, returns true for everything. 0 will be false for everything.
Usage:
consttenth = everyNth(10); window.addEventListener(`pointermove`, evt=> { if (!tenth(evt)) return; // Filter out // Continue processing, it is the 10th thing.
});
Alternative:
window.addEventListener(`pointermove`, everyNth(10, evt=> { // Do something with tenth item... });
Returns true for every _n_th call, eg 2 for every second call.
If
nth
is 1, returns true for everything. 0 will be false for everything.Usage:
Alternative: