Creates a debounced function that delays the invocation of the provided function
until after the specified wait time has passed since the last time it was invoked.
Parameters
fn: Function
The function to debounce.
wait: number
The number of milliseconds to wait before calling the function.
Returns (...args:any[])=>void
A debounced function.
Example
constdebouncedLog = debounce((message: string) =>console.log(message), 500); debouncedLog("Hello"); // Will log "Hello" after 500ms if no other calls happen in that time.
Creates a debounced function that delays the invocation of the provided function until after the specified
waittime has passed since the last time it was invoked.