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

limiter

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

limiter - npm Package Compare versions

Comparing version 0.0.2 to 1.0.0

.npmignore

16

lib/tokenBucket.js

@@ -59,4 +59,6 @@

removeTokens: function(count, callback) {
var self = this;
// Is this an infinite size bucket?
if (!this.maxBurst) {
if (!this.bucketSize) {
callback(null, count, Number.POSITIVE_INFINITY);

@@ -81,11 +83,9 @@ return true;

(count - this.content) * (this.interval / this.tokensPerInterval));
setTimeout(function() { removeTokens(count, callback); }, waitInterval);
setTimeout(function() { self.removeTokens(count, callback); }, waitInterval);
return false;
}
if (parent) {
var self = this;
if (this.parentBucket) {
// Remove the requested from the parent bucket first
return parent.removeTokens(count, function(err, remainingTokens) {
return this.parentBucket.removeTokens(count, function(err, remainingTokens) {
if (err) {

@@ -106,3 +106,3 @@ callback(err, null);

this.content -= count;
callback(null, self.content);
callback(null, this.content);
return true;

@@ -127,3 +127,3 @@ }

var dripAmount = deltaMS * (this.tokensPerInterval / this.interval);
this.content = Math.min(this.content + dripAmount, maxBurst);
this.content = Math.min(this.content + dripAmount, this.bucketSize);
}

@@ -130,0 +130,0 @@ };

{
"name": "limiter",
"description": "A generic rate limiter for node.js. Useful for API clients, web crawling, or other tasks that need to be throttled",
"version": "0.0.2",
"version": "1.0.0",
"author": "John Hurliman <jhurliman@cull.tv>",
"dependencies": { },
"devDependencies": { },
"devDependencies": {
"assert": "0.4.9",
"vows": "0.6.3"
},
"keywords": ["rate", "limiting", "throttling"],

@@ -9,0 +12,0 @@ "repository": "git://github.com/jhurliman/node-rate-limiter",

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