Throttle¶
Limits the maximum number of times a given function can be called over time.
Parameters¶
int - delay¶
milliseconds to delay before running fn
function - fn¶
the function to run after the delay
Return Value¶
A function, decorated with the throttle logic.
Example Usage¶
import throttle from '@mvps-genesis/throttle';
// storing as a variable to be called later
const throttled = throttle( 200, () => { console.log( 'Fire!' ) } );
throttled();
// self-executing
throttle( 200, () => { console.log( 'Fire!' ) } )();