Fix #277
This commit is contained in:
parent
c2cd04f760
commit
6aecb32c89
3 changed files with 65 additions and 6 deletions
|
|
@ -76,16 +76,16 @@ module.exports = {
|
|||
if (isNaN(cooldown))
|
||||
cooldown = burst / sustained;
|
||||
|
||||
// Haven't reached burst cap yet, allow
|
||||
if (this.count < burst) {
|
||||
this.count++;
|
||||
// Cooled down, allow and clear buffer
|
||||
if (this.lastTime < Date.now() - cooldown*1000) {
|
||||
this.count = 1;
|
||||
this.lastTime = Date.now();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Cooled down, allow and clear buffer
|
||||
if (this.lastTime < Date.now() - cooldown*1000) {
|
||||
this.count = 0;
|
||||
// Haven't reached burst cap yet, allow
|
||||
if (this.count < burst) {
|
||||
this.count++;
|
||||
this.lastTime = Date.now();
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue