From 98358d5c09fa63174c07bf978ffecb4686001cd8 Mon Sep 17 00:00:00 2001 From: Christian Weimann Date: Sat, 26 Aug 2023 08:11:13 +0200 Subject: [PATCH] Improve comments --- utils/timer.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils/timer.js b/utils/timer.js index 3c62bd2..305cac5 100644 --- a/utils/timer.js +++ b/utils/timer.js @@ -15,30 +15,35 @@ class Timer { } cancel(identifier) { + // Return if no timer with the respactive identifier is available if (!this.#timers.hasOwnProperty(identifier)) { console.debug(`No timer with identifier ${identifier} available to cancel`); return false; } + // Check if timer is active if (!this.#timers[identifier].isActive()) { console.debug(`Timer with identifier ${identifier} not running. Cancel anyway`); } else { console.debug(`Cancel timer with identifier ${identifier}`); } + // Cancel timer this.#timers[identifier].cancel(); delete this.#timers[identifier]; } cancelAll() { - + // Fetch timers let timers = Object.keys(this.#timers); + // Return if no timers available if (timers.length == 0) { console.debug('No timers available to cancel'); return false; } + // Cancel all timers for (let timer of timers) { this.cancel(timer); }