An open API service indexing awesome lists of open source software.

https://github.com/webfactory/debounce


https://github.com/webfactory/debounce

Last synced: 5 months ago
JSON representation

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));
```