From 954d2aded48a12a9b1feb5223cd75944c1cd58a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 12 May 2024 19:58:40 +0200 Subject: [PATCH] cluster: replace `forEach` with `for-of` loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit PR-URL: https://github.com/nodejs/node/pull/50317 Reviewed-By: James M Snell Reviewed-By: Antoine du Hamel --- lib/internal/cluster/child.js | 4 ++-- lib/internal/cluster/primary.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/internal/cluster/child.js b/lib/internal/cluster/child.js index 1bddd3ca0ac103..092e61cdd1f6b0 100644 --- a/lib/internal/cluster/child.js +++ b/lib/internal/cluster/child.js @@ -270,14 +270,14 @@ function _disconnect(primaryInitiated) { } } - handles.forEach((handle) => { + for (const handle of handles.values()) { waitingCount++; if (handle[owner_symbol]) handle[owner_symbol].close(checkWaitingCount); else handle.close(checkWaitingCount); - }); + } handles.clear(); checkWaitingCount(); diff --git a/lib/internal/cluster/primary.js b/lib/internal/cluster/primary.js index 945f440cd19797..107ab258a47e04 100644 --- a/lib/internal/cluster/primary.js +++ b/lib/internal/cluster/primary.js @@ -152,10 +152,10 @@ function removeWorker(worker) { function removeHandlesForWorker(worker) { assert(worker); - handles.forEach((handle, key) => { + for (const { 0: key, 1: handle } of handles) { if (handle.remove(worker)) handles.delete(key); - }); + } } cluster.fork = function(env) {