This commit is contained in:
calzoneman 2013-09-06 15:53:23 -05:00
parent c2cd04f760
commit 6aecb32c89
3 changed files with 65 additions and 6 deletions

View file

@ -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;
}