Socket
Socket
Sign inDemoInstall

bottleneckp

Package Overview
Dependencies
0
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

test/general.js

22

lib/Bottleneck.js

@@ -60,10 +60,24 @@ var PriorityQueue = function(size) {

function Bottleneck(maxConcurrent, rateLimit, priorityRange) {
function Bottleneck(maxConcurrent, rateLimit, priorityRange, defaultPriority) {
if(isNaN(maxConcurrent) || isNaN(rateLimit)) {
throw "maxConcurrent and rateLimit must be numbers";
}
priorityRange = priorityRange || 1;
if(isNaN(priorityRange)) {
throw "priorityRange must be a number";
}
priorityRange = parseInt(priorityRange);
defaultPriority = defaultPriority ? defaultPriority : Math.floor(priorityRange/2);
if(isNaN(defaultPriority)) {
throw "defaultPriority must be a number";
}
defaultPriority = defaultPriority >= priorityRange ? priorityRange-1 : defaultPriority;
defaultPriority = parseInt(defaultPriority);
this.rateLimit = parseInt(rateLimit);
this.maxConcurrent = this.rateLimit ? 1 : parseInt(maxConcurrent);
this._waitingClients = new PriorityQueue(priorityRange || 1);
this._priorityRange = priorityRange || 1;
this._waitingClients = new PriorityQueue(priorityRange);
this._priorityRange = priorityRange;
this._defaultPriority = defaultPriority;
this._nextRequest = Date.now();

@@ -81,3 +95,3 @@ this._tasksRunning = 0;

}
priority = priority && + priority | 0 || 0;
priority = priority && + priority | 0 || self._defaultPriority;
priority = priority > self._priorityRange-1 ? self._priorityRange-1 : priority;

@@ -84,0 +98,0 @@ this._waitingClients.enqueue(clientCallback, priority);

9

package.json
{
"name": "bottleneckp",
"version": "1.0.1",
"version": "1.0.2",
"description": "asynchronous rate limiter with priority",
"main": "./lib/Bottleneck.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "./node_modules/mocha/bin/mocha test/index.js"
},

@@ -27,3 +27,6 @@ "repository": {

},
"homepage": "https://github.com/darrenqc/BottleneckP#readme"
"homepage": "https://github.com/darrenqc/BottleneckP#readme",
"devDependencies": {
"mocha":"*"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc