New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

debounce-execution

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

debounce-execution

Debounce will collapse multiple requests (if any) for a named task into one invocation which will execute after the given wait time has passed.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

debounce-execution

Debounce will collapse multiple requests (if any) for a named task into one invocation which will execute after the given wait time has passed. By default the latest request for a task will be executed after the given wait time, but it is possible to execute the first request and block any future requests until the given wait time has passed.

Installation

$ npm install debounce-execution --save

Examples

Debounce sports one public static method: debounce(jobName: String, func: function, ?waitTime: number, ?immediate: boolean).

This allows you to do:

    let scrollhandler = Debounce.debounce("collapseScroll", onScroll, 200);
    container.addEventListener("scroll", scrollHandler);
    
    function onScroll () {
        // Any scroll events fired within the last 200ms has been collapsed and only
        // the last event made this function invocate.
    }

If immediate is true, the first request is executed and then any requests within the given waitTime will be blocked:

    let touchStartHandler = Debounce.debounce("collapseTouchStart", onTouchStart, 100, true);
    container.addEventListener("touchstart", touchStartHandler);
    
    function onTouchStart (e) {
        //Only the first touch event within the next 100ms will invocate this function.
    }

Usage

Simply do npm install debounce-execution --save;

And then all that's left is to import what you want:

import Debounce from "debounce-execution";

or

const Debounce = require("debounce-execution");

License

Copyright (c) 2016 Dlmma IVS. Released under the MIT license.

Keywords

FAQs

Package last updated on 27 Jun 2016

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