Limits the rate at which a function can be called.
Throttling ensures a function is called at most once per duration period. During the throttle period, subsequent calls return the last computed result.
Example
consta = throttle(1000, (x: number) =>x * 2); a(1); // 2 (executes immediately) a(2); // 2 (returns previous result, function not called) // After 1000ms a(3); // 6 (executes again)
Limits the rate at which a function can be called.
Throttling ensures a function is called at most once per duration period. During the throttle period, subsequent calls return the last computed result.
Example