Function.throttle >= 0.1.9

Purpose

Create a new function that will only be able to be called once per given ms

Syntax

Function.throttle ( Functionfnc Numberminimum_wait= 5 Booleanimmediate= false Booleanreset_on_call= false );

Parameters

fnc
The function to throttle
minimum_wait
Minimum time to wait between executions
immediate
If true, execute the first execution immediately
reset_on_call
Reset the timer on each call

Return values

Function

Examples

Basic throttled function, created with default values

var throttledLogger = Function.throttle(function doLog(message) {
    console.log('LOG:', message);
});

// Even though it's called 10 times,
// only the last call will actually execute the `doLog` function
for (var i = 1; i <= 10; i++) {
    throttledLogger(i);
}>>> 10