throttle function
Throttle a function to limit call frequency.
Example
const throttledResize = throttle(() => layout(), 100);
window.addEventListener('resize', throttledResize);Signature
throttle<T extends (...args: any[]) => any>(fn: T, interval: number): (...args: Parameters<T>) => void
Type Parameters
- T
Function type
Parameters
- fn
Function to throttle
- interval
Minimum interval in milliseconds between calls
Returns
Throttled function