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

@d-fischer/rate-limiter

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@d-fischer/rate-limiter - npm Package Compare versions

Comparing version 0.7.2 to 0.7.3

18

lib/limiters/PartitionedTimeBasedRateLimiter.js

@@ -39,3 +39,8 @@ "use strict";

queue.push(reqSpec);
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " for ").concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " was reached, waiting for a free bucket entry; queue size is ").concat(queue.length));
if (usedFromBucket + queue.length >= _this._bucketSize) {
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " for ").concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " was reached, waiting for ").concat(_this._paused ? 'the limiter to be unpaused' : 'a free bucket entry', "; queue size is ").concat(queue.length));
}
else {
_this._logger.info("Enqueueing request for ".concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " because the rate limiter is paused; queue size is ").concat(queue.length));
}
break;

@@ -45,7 +50,14 @@ }

reqSpec.resolve(null);
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " for ").concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " was reached, dropping request and returning null"));
if (_this._paused) {
_this._logger.info("Returning null for request for ".concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " because the rate limiter is paused"));
}
else {
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " for ").concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " was reached, dropping request and returning null"));
}
break;
}
case 'throw': {
reqSpec.reject(new RateLimitReachedError_1.RateLimitReachedError("Request dropped because the rate limit for ".concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " was reached")));
reqSpec.reject(new RateLimitReachedError_1.RateLimitReachedError("Request dropped because ".concat(_this._paused
? 'the rate limiter is paused'
: "the rate limit for ".concat(partitionKey ? "partition ".concat(partitionKey) : 'default partition', " was reached"))));
break;

@@ -52,0 +64,0 @@ }

@@ -35,3 +35,8 @@ "use strict";

_this._queue.push(reqSpec);
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " was reached, waiting for a free bucket entry; queue size is ").concat(_this._queue.length));
if (_this._usedFromBucket + _this._queue.length >= _this._bucketSize) {
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " was reached, waiting for ").concat(_this._paused ? 'the limiter to be unpaused' : 'a free bucket entry', "; queue size is ").concat(_this._queue.length));
}
else {
_this._logger.info("Enqueueing request because the rate limiter is paused; queue size is ".concat(_this._queue.length));
}
break;

@@ -42,6 +47,12 @@ }

_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " was reached, dropping request and returning null"));
if (_this._paused) {
_this._logger.info('Returning null for request because the rate limiter is paused');
}
else {
_this._logger.warn("Rate limit of ".concat(_this._bucketSize, " was reached, dropping request and returning null"));
}
break;
}
case 'throw': {
reqSpec.reject(new RateLimitReachedError_1.RateLimitReachedError('Request dropped because the rate limit was reached'));
reqSpec.reject(new RateLimitReachedError_1.RateLimitReachedError("Request dropped because ".concat(_this._paused ? 'the rate limiter is paused' : 'the rate limit was reached')));
break;

@@ -48,0 +59,0 @@ }

2

package.json
{
"name": "@d-fischer/rate-limiter",
"version": "0.7.2",
"version": "0.7.3",
"description": "Rate limit your requests.",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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