Rhythm Filter
Filters function calls within the "EVERY" filtration interval.
If a filtration interval ends, the last function attempted in the interval is called.
Example
import { RHYTHM_FILTER } from '@localsource/rhythm-filter' const RF = RHYTHM_FILTER ({ EVERY: 500 }); function WINDOW_SIZE_CHANGE (EVENT) { RF.ATTEMPT (({ DATE, IS_LAST }) => { console.log ("WINDOW SIZE CHANGED", { EVENT }) }); } window.addEventListener ("resize", WINDOW_SIZE_CHANGE); // window.removeEventListener ("resize", WINDOW_SIZE_CHANGE)
Example: With: const RF = RHYTHM_FILTER ({ EVERY: 500 }); Given an array of calls at: [ 0, 200, 604, 1000, 1139, 1141, 1159 ] Filtration intervals are: 0 TO 500 604 TO 1104 1139 TO 1639 Therefore: [ 200, 1000, 1141 ] are filtered 1159 is invoked at 1641 because no other call was made between 1141 and 1641.
Publishing
[TCSH] npm publish --access public