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

rolling-window-throttler

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rolling-window-throttler

rolling window throttler - Count invocations per key and returns true if invocation allowed within provided durationWindow and max invocations per key

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by150%
Maintainers
1
Weekly downloads
 
Created
Source

Rolling Window Throttler Build Status npm version

Count invocations per key and returns true if invocation allowed within provided durationWindow and max invocations per key.

Install

npm install --save rolling-window-throttler

Usage

const rollingWindowThrottler = require('rolling-window-throttler')
const throttler = rollingWindowThrottler({max: 1, durationWindow: '1s'})

if (throttler.tryAcquire('some-key')) {
  // not throttled, perform logic
}

Api

({max, durationWindow}): RollingWindowThrottler

Create new instance of RollingWindowThrottler.

Parameters:

  • max - int, mandatory, number of allowed invocations for a key;
  • durationWindow - mandatory and can be one of:
    • ms, ex. {durationWindow: 1000};
    • verbal period, ex. {durationWindow: '1m' / '1s' / '1hr 20mins'} as per parse-duration.

RollingWindowThrottler.tryAcquire(key): boolean

Returns true if not throttled for provided key.

License

Copyright (c) 2014 Wix.com Ltd. All Rights Reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file in the root of the source tree.

Keywords

FAQs

Package last updated on 21 Nov 2017

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