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

debouncing

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

debouncing

Debouncing and throttling events module from Glize library.

  • 21.6.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by3.71%
Maintainers
1
Weekly downloads
 
Created
Source

Debouncing Tweet

Build Status License NPM version Website

Debouncing and throttling events module from Glize library.

Usage

npm install debouncing --save
import {debounce, throttle} from 'debouncing';

const onResize = (event) => {
  console.log('height', window.innerHeight);
  console.log('width', window.innerWidth);
};

/**
 * In the debouncing technique, no matter how many times the user fires the 
 * event, the attached function will be executed only after the specified 
 * time once the user stops firing the event.
 * 
 * Returns a function, that, as long as it continues to be invoked, will not
 * be triggered. The function will be called after it stops being called for
 * N milliseconds.
 * @param {!Function} func The function to execute.
 * @param {number=} timeout The timeout in milliseconds.
 * @return {!Function} Returns a function, that, as long as it continues 
 *     to be invoked, will not be triggered.
 */
window.addEventListener('resize', debounce(onResize, 250), false);

/**
 * Throttling is a technique in which, no matter how many times the user 
 * fires the event, the attached function will be executed only once in a 
 * given time interval.
 * 
 * Returns a function, that, as long as it continues to be invoked, will only
 * trigger every N milliseconds.
 * @param {!Function} func The function to execute.
 * @param {number=} timeout The timeout in milliseconds.
 * @return {!Function} Returns a function, that, as long as it continues 
 *     to be invoked, will only trigger every N milliseconds.
 */
window.addEventListener('resize', throttle(onResize, 250), false);

For more information please visit Glize project page.

Keywords

FAQs

Package last updated on 20 Jun 2021

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