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

leaky-bucket

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leaky-bucket - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

19

lib/LeakyBucket.js

@@ -139,6 +139,25 @@ (function() {

/**
* returns ifno about the counters fo the bucket
*
* @returns {object} info
*/
, getInfo: function() {
// refill
this.left += Math.min((Date.now()-this.last)/1000/this.refillRate, this.capacity);
this.last = Date.now();
return {
left: this.left
, interval: this.slotSize
, capacity: this.capacity
};
}
/**

@@ -145,0 +164,0 @@ * pause the leaky bucket for n seconds,

2

package.json
{
"name" : "leaky-bucket"
, "description" : "A fast and efficient leaky bucket implementation"
, "version" : "2.0.1"
, "version" : "2.1.0"
, "homepage" : "https://github.com/eventEmitter/leaky-bucket"

@@ -6,0 +6,0 @@ , "author" : "Michael van der Weg <michael@joinbox.com> (http://joinbox.com/)"

@@ -118,2 +118,14 @@ # leaky-bucket

### Getting information from the bucket
By calling the getInfo method the bucket returns information about its internals
bucket.getInfo();
{
left: 100
, interval: 60
, capacity: 100
}
## Flags

@@ -120,0 +132,0 @@

@@ -385,3 +385,20 @@

});
it('should return info about the counters', function() {
var bucket = new LeakyBucket(100, 60, 10);
var info = bucket.getInfo();
assert.equal(info.left, 100);
assert.equal(info.capacity, 100);
assert.equal(info.interval, 60);
});
});
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