debouncer-js
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

debouncer-js

Table of Contents

Installation

To install, you can use npm:

$ npm install --save debouncer-js

To install debouncer-js in CDN app:

  • Add this CDN script tag before your JS files (for example from unpkg):

       <script src="https://unpkg.com/debouncer-js@1.0.2/debouncer.js"
       crossorigin="anonymous"
       referrerpolicy="no-referrer"></script>
    

Example

Here is a simple example of debouncer-js being used in an app

import Debouncer from 'debouncer-js';

const debouncer = new Debouncer();

function func(...args) {
    // Do something
}

const debouncedFunc = debouncer.debounce(func, 500);

function onChangeSomething() {
    const args = [/*Some args*/];
    debouncedFunc(...args); 
    // It will call func when ever 
    // the onChangeSomething call last more than 500ms.
  
debouncer.clear(func); // Or func.name ---- Clear the func from being called in the delay time and latest call won't be trigger.
debouncer.flush(); // Remove all debounced functions calls  
}

Package Sidebar

Install

npm i debouncer-js

Weekly Downloads

7

Version

1.0.8

License

MIT

Unpacked Size

5.08 kB

Total Files

5

Last publish

Collaborators

  • mohammadhakimi