debounce
Creates a debounced function that delays invocation until after a specified wait time has elapsed since the last call.
fn
: The function to debouncedelay
: Debounce delay in milliseconds (default: 500)Returns a debounced function with additional control methods:
cancel()
: Cancel pending executionflush()
: Execute immediatelypending()
: Check if execution is pendingthis
contextdebounceSync
for synchronous functions