https://github.com/webfactory/debounce
https://github.com/webfactory/debounce
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/webfactory/debounce
- Owner: webfactory
- Created: 2025-08-27T12:44:51.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-27T12:46:21.000Z (10 months ago)
- Last Synced: 2025-08-27T21:15:32.156Z (10 months ago)
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# debounce Utility
The `debounce` utility is a simple JavaScript function that limits the rate at which a particular callback function can be executed. It ensures that a function is only called after a specified delay period has passed since the last time it was invoked. This is particularly useful for optimizing performance in scenarios like handling user input events, where rapid calls can lead to unnecessary processing.
## Installation
```
npm install @webfactoryde/debounce
```
## Usage
Import the `debounce` function in your module(s) and pass a callback that you want to rate-limit:
```javascript
// your module
import debounce from '@webfactoryde/debounce';
function coolFunction() {
// do cool stuff
}
window.addEventListener('resize', debounce(coolFunction, 200));
```