Add time unit suffixes to variables (#561)

Add suffixes like Ms and Ns to variables whos time unit is not in
seconds.  This is aligning with a new code style of putting units
on variables that are not in SI base units.
This commit is contained in:
Hornwitser authored and GitHub committed 2024-01-20 13:26:55 +01:00
1 parent 9842705eb9
commit c53781d16c
38 files changed
+221 -201

No files matched your search

+5 -5
View File
@@ -29,7 +29,7 @@ export default class RateLimiter {
*/
action?: () => void;
private _lastRun = 0;
private _lastRunMs = 0;
private _runTimeout?: ReturnType<typeof setTimeout>;
/**
@@ -60,15 +60,15 @@ export default class RateLimiter {
*/
activate() {
let now = Date.now();
if (now < this._lastRun + 1000 / this.maxRate) {
if (now < this._lastRunMs + 1000 / this.maxRate) {
if (!this._runTimeout && this.action) {
this._runTimeout = setTimeout(() => {
this._runTimeout = undefined;
this._lastRun = Date.now();
this._lastRunMs = Date.now();
if (this.action) {
this.action();
}
}, this._lastRun + 1000 / this.maxRate - now);
}, this._lastRunMs + 1000 / this.maxRate - now);
}
return false;
}
@@ -79,7 +79,7 @@ export default class RateLimiter {
this._runTimeout = undefined;
}
this._lastRun = now;
this._lastRunMs = now;
if (this.action) {
this.action();
}