Skip to content

webfactory/debounce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

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:

// your module
import debounce from '@webfactoryde/debounce';

function coolFunction() {
    // do cool stuff
}

window.addEventListener('resize', debounce(coolFunction, 200));

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published