Skip to content

debounce

debounce<T>(params): Debounced<T>

Defined in: async/debounce/index.ts:24

Creates a debounced version of a function that delays invocation until after ms milliseconds have elapsed since the last call.

T extends (…args) => unknown

DebounceParams<T>

The parameters object

Debounced<T>

The debounced function with a .cancel() method

const debouncedFn = debounce({ fn: search, ms: 300 });
debouncedFn("query");
debouncedFn.cancel(); // cancel pending call

delay call, wait idle, input delay, search delay

Error if fn is not a function

Error if ms is not a number or is negative