API Reference

debounce

Debounce a function with a configurable wait and optional immediate leading call.

Official Documentation ↗
CompatibilityThis documentation covers version v2.1.0. Check the official docs for the latest API surface.

Installation

npmnpm install debounce
pnpmpnpm add debounce

Methods

debounce is debounce a function with a configurable wait and optional immediate leading call.

Key Features

  • resilience: Designed for resilience scenarios with a focused API surface.

Installation

npm install debounce

Usage

API reference evidence

Fetched from official sources on 2026-11-08T18:27:00+08:00 via WebFetch https://cdn.jsdelivr.net/gh/sindresorhus/debounce@latest/readme.md.

FAQ

What is the difference between debounce and throttle?
Debounce delays until activity stops for wait ms; throttle guarantees at most one invocation per wait window.
Does debounce support leading and trailing edges?
Yes, pass { leading: true, trailing: false } to control when the function fires.
Is debounce safe for use in React effects?
Yes, but cancel pending calls on cleanup to avoid setState after unmount.