Creates a throttled function that only invokes the provided function at most once every wait milliseconds.
If the function is invoked multiple times in quick succession, only the first call in the given wait period will be executed.
Parameters
fn: Function
The function to throttle.
wait: number
The number of milliseconds to wait between invocations.
Returns (...args:any[])=>void
A throttled function.
Example
constthrottledLog = throttle((message: string) =>console.log(message), 1000); throttledLog("Hello"); // Will log "Hello" throttledLog("World"); // Will be ignored because it's within the 1000ms window.
Creates a throttled function that only invokes the provided function at most once every
waitmilliseconds. If the function is invoked multiple times in quick succession, only the first call in the givenwaitperiod will be executed.