debounce-now
v1.0.0
Published
A tiny, zero-dependency debounce function for JavaScript and React.
Downloads
5
Maintainers
Readme
debounce-now
A tiny, zero-dependency debounce function for JavaScript and React. Useful for input handlers, API calls, and more.
Install
npm install debounce-nowUsage
import debounce from 'debounce-now';
const log = debounce((text) => console.log(text), 300);
log('Hello');
log('World');
// Only "World" will be logged after 300msTypescript Usage
debounce(fn: Function, delay?: number): Functionfn– The function to debouncedelay– Delay in milliseconds (default: 300)
Features
- Runs a function after a short delay.
- Ignores fast repeated calls.
- Helps reduce extra work like API calls.
- Useful in input fields, scroll, and resize.
- You can set your own delay time.
- Very small and easy to use.
Examples
- Search inputs
- Resize/scroll events
- Button click limiters
