debounce
- Version 2.2.0
- Published
- 7.15 kB
- No dependencies
- MIT license
Install
npm i debounce
yarn add debounce
pnpm add debounce
Overview
Delay function calls until a set time elapses after the last invocation
Index
Functions
Type Aliases
Functions
function debounce
debounce: <F extends AnyFunction>( function_: F, wait?: number, options?: { immediate: boolean }) => debounce.DebouncedFunction<F>;
Creates a debounced function that delays execution until
wait
milliseconds have passed since its last invocation.Set the
immediate
option totrue
to execute the function immediately at the start of thewait
interval, preventing issues such as double-clicks on a button.The returned function has the following methods:
-
.isPending
indicates whether the debounce delay is currently active. -.clear()
cancels any scheduled executions. -.flush()
if an execution is scheduled then it will be immediately executed and the timer will be cleared. -.trigger()
executes the function immediately and clears the timer if it was previously set.
Type Aliases
type DebouncedFunction
type DebouncedFunction<F extends AnyFunction> = { (...arguments_: Parameters<F>): ReturnType<F> | undefined; readonly isPending: boolean; clear(): void; flush(): void; trigger(): void;};
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (2)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/debounce
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/debounce)
- HTML<a href="https://www.jsdocs.io/package/debounce"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3279 ms. - Missing or incorrect documentation? Open an issue for this package.