Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@merry-solutions/debounce

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@merry-solutions/debounce

Simple debounce factory function that creates an async version of a passed function which executes after a given delay. Built with typescript and promises.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

debounce

Simple debounce factory function that creates an async version of a passed function which executes after a given delay. Built with typescript and promises.

Installation

npm i @merry-solutions/debounce

Usage

Simply create a debounced version of any function. Passing a function you get back a tuple consisting of a debounced version of the passed function and an additional function that can cancel the debounced version's pending execution at any time.

Running debounced function:

import { debounce } from '@merry-solutions/debounce';

function saySomething(): void {
  console.log('Something');
}

const [debouncedSaySomething] = debounce(saySomething, 100);

// Is going to say something only once
for (let x = 0; x < 99; x++) {
  debouncedSaySomething();
}

Cancelling debounced function before execution:

import { debounce } from '@merry-solutions/debounce';

function saySomething(): void {
  console.log('Something');
}

const [debouncedSaySomething, cancel] = debounce(saySomething, 100);

// Won't say anything
for (let x = 0; x < 99; x++) {
  debouncedSaySomething();
}
cancel();

Simple as that :)

Keywords

FAQs

Package last updated on 09 Feb 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc