Initial commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
class Limiter {
|
||||
constructor(info) {
|
||||
this.countThreshold = info.countThreshold;
|
||||
this.timeThreshold = info.timeThreshold;
|
||||
this.nextTime = 0;
|
||||
this.time = 0;
|
||||
this.count = 0;
|
||||
};
|
||||
|
||||
update() {
|
||||
if (performance.now() - this.time < this.timeThreshold) this.count++;
|
||||
else {
|
||||
this.time = performance.now();
|
||||
this.count = 1;
|
||||
};
|
||||
|
||||
return this.count > this.countThreshold;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Limiter;
|
||||
Reference in New Issue
Block a user