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

rate-limiter-flexible

Package Overview
Dependencies
Maintainers
1
Versions
164
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.4.0 to 0.4.1

8

lib/component/BlockedKeys/BlockedKeys.js
module.exports = class BlockedKeys {
constructor() {
this._keys = {}; // {'key': 1526279430331}
this._length = 0;
this._addedKeysAmount = 0;
}

@@ -16,3 +16,3 @@

this._length = Object.keys(this._keys).length;
this._addedKeysAmount = Object.keys(this._keys).length;
}

@@ -28,4 +28,4 @@

this._keys[key] = Date.now() + sec * 1000;
this._length++;
if (this._length > 999) {
this._addedKeysAmount++;
if (this._addedKeysAmount > 999) {
this.collectExpired();

@@ -32,0 +32,0 @@ }

@@ -46,3 +46,3 @@ const expect = require('chai').expect;

blockedKeys.add('key1', 1);
expect(Object.keys(blockedKeys._keys).length === 1 && blockedKeys._length === 1).to.equal(true);
expect(Object.keys(blockedKeys._keys).length === 1 && blockedKeys._addedKeysAmount === 1).to.equal(true);
done();

@@ -56,3 +56,3 @@ }, 1001);

blockedKeys.msBeforeExpire('key');
expect(Object.keys(blockedKeys._keys).length === 1 && blockedKeys._length === 1).to.equal(true);
expect(Object.keys(blockedKeys._keys).length === 1 && blockedKeys._addedKeysAmount === 1).to.equal(true);
done();

@@ -59,0 +59,0 @@ }, 1001);

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

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

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