Debounce promise-returning and async functions with configurable leading/trailing edge and abort signal support.
p-debounce is a JavaScript utility library that provides debouncing functionality specifically designed for promise-returning and async functions. It helps prevent excessive API calls, resource-intensive operations, and race conditions by delaying function execution until after a specified wait time has elapsed since the last call.
JavaScript developers working with async/await patterns who need to optimize API calls, handle user input events, or manage expensive asynchronous operations in both Node.js and browser environments.
Unlike general debounce utilities, p-debounce is specifically designed for Promise-based workflows with features like Promise deduplication, abort signal support, and configurable edge behavior, making it ideal for modern asynchronous JavaScript applications.
Debounce promise-returning & async functions
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Built specifically for async/await and Promise-based functions, eliminating manual promise handling and ensuring seamless integration in modern JavaScript apps, as shown in the usage examples.
Offers leading/trailing edge execution via the 'before' option and queueing of latest arguments with 'after', providing flexibility for different async scenarios like API calls or data saves.
Supports cancellation using standard AbortSignal, allowing developers to abort debounced operations mid-flight, which is useful for dynamic user interactions or cleanup.
Includes pDebounce.promise with deduplication to return the same promise for concurrent calls, preventing redundant executions in cases like duplicate button clicks.
Only works with promise-returning functions; for synchronous debouncing, users must rely on separate utilities like 'debounce-fn', adding overhead if both types are needed.
Multiple options (before, after, signal) and two API modes (pDebounce vs. pDebounce.promise) can confuse newcomers, requiring a deeper understanding of debouncing concepts to use effectively.
As a specialized library, it lacks broader ecosystem support (e.g., framework integrations or plugins) compared to general-purpose debounce tools, potentially limiting community resources.