From 2b4e46f07d59903097bb80831d214c6897c555fa Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 20 Jan 2022 06:35:12 -0800 Subject: [PATCH] timers: check for nullish instead of falsy in loops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This prepares the code for the no-cond-assign ESLint rule. PR-URL: https://github.com/nodejs/node/pull/41614 Reviewed-By: Tobias Nießen Reviewed-By: Anna Henningsen --- lib/internal/timers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/timers.js b/lib/internal/timers.js index 2441d7b194a72b..f48b4057a37ef1 100644 --- a/lib/internal/timers.js +++ b/lib/internal/timers.js @@ -490,7 +490,7 @@ function getTimerCallbacks(runNextTicks) { let list; let ranAtLeastOneList = false; - while (list = timerListQueue.peek()) { + while ((list = timerListQueue.peek()) != null) { if (list.expiry > now) { nextExpiry = list.expiry; return refCount > 0 ? nextExpiry : -nextExpiry; @@ -511,7 +511,7 @@ function getTimerCallbacks(runNextTicks) { let ranAtLeastOneTimer = false; let timer; - while (timer = L.peek(list)) { + while ((timer = L.peek(list)) != null) { const diff = now - timer._idleStart; // Check if this loop iteration is too early for the next timer.