diff --git a/shared/js/timers.js b/shared/js/timers.js index 9807bc48e..d9e158c98 100644 --- a/shared/js/timers.js +++ b/shared/js/timers.js @@ -83,8 +83,9 @@ class Timer { } tick() { - if (this.interval === 0 || Date.now() - this.lastTick > this.interval) { - const start = Date.now(); + const now = Date.now(); + if (this.interval === 0 || now - this.lastTick > this.interval) { + const start = now; try { this.callback(); } catch (e) { @@ -202,7 +203,7 @@ globalThis.clearTimeout = (timeout) => { }; function tick() { - for (const [_, timer] of timers) { + for (const timer of timers.values()) { timer.tick(); } }