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

throttle-await

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

throttle-await

throttle-await provides a simple class that provides an async "wait" function that waits while throttled

  • 1.0.0
  • latest
  • npm
  • Socket score

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

throttle-await

throttle-await provides a simple class that provides an async "wait" function that waits while throttled.

Install

npm i throttle-await

Usage

import Throttle from "../src/index";
import tape from 'tape';

tape('throttle', (t) => {
  (async () => {
    const throttled = new Throttle(1000, 2); // 2 times per second

    await throttled.wait();
    const first = new Date();
    console.log(`first = ${first.getTime()}`);

    await throttled.wait();
    const second = new Date();
    console.log(`second = ${second.getTime()}`);
    t.ok(second.getTime() - first.getTime() < 500, '2nd call happens immediately');
    
    await throttled.wait();
    const third = new Date();
    console.log(`third = ${third.getTime()}`);
    t.ok(third.getTime() - second.getTime() > 500, '3rd call is throttled');

    throttled.cancel();
    
    t.end();
  })();
});

FAQs

Package last updated on 19 Jun 2020

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