🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

@cfware/debouncer

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cfware/debouncer

Debouncer class

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

@cfware/debouncer NPM Version

Debouncer class

Usage

import Debouncer from '@cfware/debouncer';

const debouncer = new Debouncer(() => {
	console.log('debounced callback');
});

// Only run the callback once.
debouncer.run();
setTimeout(() => debouncer.run(), 50);

debouncer = new Debouncer(callback, delay, maxDelays)

  • callback is the callback which is to be rate controlled. Required, must be a function.
  • delay is the number of milliseconds to wait before running the callback. Optional, default 100.
  • maxDelays maximum number of full delays before callback is run. Optional, default 2.

debouncer.run(immediately = false)

This schedules a call to the callback.

If immediately is enabled the callback is run immediately.

debouncer.flush()

This forces the callback to run immediately.

debouncer.clear()

Cancel any scheduled runs of the callback.

FAQs

Package last updated on 15 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts