speed-limiter
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -18,3 +18,2 @@ const { TokenBucket } = require('limiter') | ||
getRate () { | ||
if (!this.bucket) return null | ||
// Note: bucketSize === tokensPerInterval | ||
@@ -70,4 +69,2 @@ return this.bucket.tokensPerInterval | ||
this.throttles.push(newThrottle) | ||
return newThrottle | ||
@@ -84,2 +81,8 @@ } | ||
_addThrottle (throttle) { | ||
if (!(throttle instanceof Throttle)) throw new Error('Throttle must be an instance of Throttle') | ||
this.throttles.push(throttle) | ||
} | ||
_removeThrottle (throttle) { | ||
@@ -86,0 +89,0 @@ const index = this.throttles.indexOf(throttle) |
@@ -16,6 +16,8 @@ const { EventEmitter } = require('events') | ||
this._setEnabled(params.enabled || params.group.enabled) | ||
this._group = params.group | ||
this._events = new EventEmitter() | ||
this._group = params.group | ||
this._destroyed = false | ||
this.setEnabled(params.enabled || params.group.enabled) | ||
this._group._addThrottle(this) | ||
} | ||
@@ -31,6 +33,9 @@ | ||
setEnabled (val = true) { | ||
_setEnabled (val = true) { | ||
if (typeof val !== 'boolean') throw new Error('Enabled must be a boolean') | ||
this._enabled = val | ||
} | ||
setEnabled (val) { | ||
this._setEnabled(val) | ||
if (this._enabled) this._events.emit('enabled') | ||
@@ -37,0 +42,0 @@ else this._events.emit('disabled') |
{ | ||
"name": "speed-limiter", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Throttle the speed of streams", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17233
365