Files
2026-08-24 22:20:36 +02:00

21 lines
497 B
JavaScript

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;