Dettle
A tiny fully-featured debounce and throttle implementation.
Install
npm install --save dettle
Usage
import {debounce, throttle} from 'dettle';
const fn = () => console.log ( 'Fired!' );
const debounced = debounce ( fn, 1000, {
leading: false,
trailing: true,
maxWait: Infinity
});
debounced ();
debounced ();
debounced.flush ();
debounced.cancel ();
const throttled = throttle ( fn, 1000, {
leading: true,
trailing: true
});
throttled ();
throttled ();
throttled.flush ();
throttled.cancel ();
License
MIT © Fabio Spampinato