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.1.1 to 1.1.2

22

lib/Cluster.js

@@ -57,2 +57,12 @@ hasProp = {}.hasOwnProperty;

Cluster.prototype._unfinishedClients = function() {
var count = 0;
var keys = this.keys();
keys.forEach(function(key) {
count += this.limiters[key]._waitingClients.size();
count += this.limiters[key]._tasksRunning;
}, this);
return count;
};
Cluster.prototype.dequeue = function(name) {

@@ -115,2 +125,8 @@ var keys = this.keys();

Object.defineProperty(Cluster.prototype, 'unfinishedClients', {
get:function() {
return this._unfinishedClients()
}
})
Object.defineProperty(Cluster.prototype, 'status', {

@@ -122,2 +138,8 @@ get:function() {

Object.defineProperty(Cluster.prototype, 'empty', {
get:function() {
return this._unfinishedClients() > 0 ? false : true
}
})
module.exports = Cluster;

2

package.json
{
"name": "bottleneckp",
"version": "1.1.1",
"version": "1.1.2",
"description": "asynchronous rate limiter with priority",

@@ -5,0 +5,0 @@ "main": "./lib/Bottleneck.js",

@@ -136,3 +136,38 @@ describe('General', function () {

})
describe('cluster property', function() {
it('should have correct waitingClients and empty property', function(done) {
var c = clusterTest(1, 0)
console.assert(c.cluster.empty === true)
console.assert(c.cluster.waitingClients === 0)
console.assert(c.cluster.unfinishedClients === 0)
c.cluster.key('1').submit(5, c.fastJob('1', 1))
console.assert(c.cluster.waitingClients === 0)
console.assert(c.cluster.unfinishedClients === 1)
c.cluster.key('1').submit(5, c.fastJob('1', 2))
console.assert(c.cluster.waitingClients === 1)
console.assert(c.cluster.unfinishedClients === 2)
console.assert(c.cluster.empty === false)
c.cluster.key('2').submit(5, c.fastJob('2', 3))
console.assert(c.cluster.waitingClients === 1)
console.assert(c.cluster.unfinishedClients === 3)
c.cluster.key('1').submit(5, c.last('1', 4, {
checkResults:[
{in:'1',out:null,value:1},
{in:'2',out:null,value:3},
{in:'1',out:null,value:2},
{in:'1',out:null,value:4}
],
checkDuration:700,
done:function() {
console.assert(c.cluster.empty === true)
console.assert(c.cluster.waitingClients === 0)
console.assert(c.cluster.unfinishedClients === 0)
done()
}
}))
})
console.assert(c.cluster.waitingClients === 2)
})
})

@@ -111,3 +111,3 @@ global.TEST = true

checkDuration: function (shouldBe) {
var results = getResults()
var results = getResults();
var min = shouldBe - 10

@@ -114,0 +114,0 @@ var max = shouldBe + 50

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