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

throttle-debounce

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

throttle-debounce

Throttle and debounce functions.

  • 5.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.2M
increased by0.87%
Maintainers
0
Weekly downloads
 
Created

What is throttle-debounce?

The throttle-debounce npm package provides utility functions to throttle and debounce function calls. Throttling ensures that a function is not called more often than the specified delay, while debouncing ensures that a function is only called after a certain amount of time has passed without it being called again.

What are throttle-debounce's main functionalities?

throttle

Throttling allows you to limit the number of times a function can be executed over time. In this example, the 'throttledFunction' will only be called at most once every 300 milliseconds, even if the 'resize' event fires more frequently.

import { throttle } from 'throttle-debounce';
const throttledFunction = throttle(300, (arg) => {
  console.log('Throttled:', arg);
});
window.addEventListener('resize', () => throttledFunction(window.innerWidth));

debounce

Debouncing allows you to delay the execution of a function until a certain amount of time has passed without it being called. In this example, the 'debouncedFunction' will only be called 300 milliseconds after the last 'keyup' event is fired.

import { debounce } from 'throttle-debounce';
const debouncedFunction = debounce(300, (arg) => {
  console.log('Debounced:', arg);
});
document.getElementById('input').addEventListener('keyup', () => debouncedFunction(document.getElementById('input').value));

Other packages similar to throttle-debounce

Keywords

FAQs

Package last updated on 24 Jun 2024

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