Function to debounce. this and arguments are forwarded.
Quiet period in milliseconds. Defaults to 250.
Fire on the leading edge instead of the trailing one. Defaults to false.
The debounced wrapper. ⚠️ It returns void — the wrapped return value is lost.
Delays a function until it has stopped being called for
waitmilliseconds.With
immediate, it fires on the leading edge instead — the first call runs at once and subsequent ones are swallowed until the window closes. Use it for search inputs and resize handlers; use throttle when you want a guaranteed cadence rather than a quiet period.⚠️ The constraint is
(...args: never[]) => unknown, NOT(...args: unknown[]) => unknown. The latter looks equivalent and is not: parameters are contravariant, sounknown[]demands a callback acceptingunknownin every position, which rejects every concretely-typed callback —(query: string) => voidincluded. That was the real signature until 31/07/2026, and it made the documented example of this very function fail to compile (TS2345, frozen three days in thetypecheck-docs-examplesbaseline).never[]is the idiom for "any function": it accepts them all, andParameters<T>still recovers the true argument types.