Creates a debounced version of a function that delays invoking fn until after delay milliseconds have elapsed since the last call.
fn
delay
The function to debounce.
The number of milliseconds to delay (default: 300ms).
A debounced function.
const log = (msg: string) => console.log(msg);const debouncedLog = debounce(log, 200);debouncedLog("Hello"); // will run 200ms after the last call Copy
const log = (msg: string) => console.log(msg);const debouncedLog = debounce(log, 200);debouncedLog("Hello"); // will run 200ms after the last call
1.1.0
Creates a debounced version of a function that delays invoking
fn
until afterdelay
milliseconds have elapsed since the last call.