Socket
Socket
Sign inDemoInstall

rate-limiter-flexible

Package Overview
Dependencies
Maintainers
1
Versions
163
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rate-limiter-flexible - npm Package Compare versions

Comparing version 0.25.1 to 0.25.2

37

lib/RateLimiterStoreAbstract.js

@@ -54,2 +54,9 @@ const RateLimiterAbstract = require('./RateLimiterAbstract');

if (res.consumedPoints > this.points) {
let blockPromise = Promise.resolve();
// Block only first time when consumed more than points
if (this.blockDuration > 0 && res.consumedPoints <= (this.points + changedPoints)) {
res.msBeforeNext = this.msBlockDuration;
blockPromise = this._block(rlKey, res.consumedPoints, this.msBlockDuration, options);
}
if (this.inmemoryBlockOnConsumed > 0 && res.consumedPoints >= this.inmemoryBlockOnConsumed) {

@@ -59,17 +66,11 @@ // Block key for this.inmemoryBlockDuration seconds

res.msBeforeNext = this.msInmemoryBlockDuration;
}
reject(res);
// Block only first time when consumed more than points
} else if (this.blockDuration > 0 && res.consumedPoints <= (this.points + changedPoints)) {
this._block(rlKey, res.consumedPoints, this.msBlockDuration, options)
.then(() => {
res.msBeforeNext = this.msBlockDuration;
reject(res);
})
.catch((err) => {
reject(err);
});
} else {
reject(res);
}
blockPromise
.then(() => {
reject(res);
})
.catch((err) => {
reject(err);
});
} else if (this.execEvenly && res.msBeforeNext > 0 && !res.isFirstInDuration) {

@@ -124,6 +125,2 @@ let delay = Math.ceil(res.msBeforeNext / (res.remainingPoints + 2));

get msInmemoryBlockDuration() {
return this._inmemoryBlockDuration * 1000;
}
set inmemoryBlockDuration(value) {

@@ -136,2 +133,6 @@ this._inmemoryBlockDuration = value ? parseInt(value) : 0;

get msInmemoryBlockDuration() {
return this._inmemoryBlockDuration * 1000;
}
get insuranceLimiter() {

@@ -138,0 +139,0 @@ return this._insuranceLimiter;

{
"name": "rate-limiter-flexible",
"version": "0.25.1",
"version": "0.25.2",
"description": "Flexible API rate limiter backed by Redis for distributed node.js applications",

@@ -5,0 +5,0 @@ "main": "index.js",

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