diff options
author | gengjiawen <technicalcute@gmail.com> | 2019-02-27 18:12:33 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-05 04:06:46 +0300 |
commit | e6305698831a91bccb8bd24a8f216d68c15f703b (patch) | |
tree | 92bdb90a1fe9c3fdddc3fc0f9d45a09606a8b7d6 /lib/internal/cluster | |
parent | d79176a3c3ed492b140439e7dab5a72027e01caf (diff) |
cluster: improve for-loop
PR-URL: https://github.com/nodejs/node/pull/26336
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/cluster')
-rw-r--r-- | lib/internal/cluster/master.js | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/internal/cluster/master.js b/lib/internal/cluster/master.js index a0e194c63ef..3869ebbd8a4 100644 --- a/lib/internal/cluster/master.js +++ b/lib/internal/cluster/master.js @@ -80,10 +80,7 @@ cluster.setupMaster = function(options) { if (message.cmd !== 'NODE_DEBUG_ENABLED') return; - var key; - for (key in cluster.workers) { - const worker = cluster.workers[key]; - + for (const worker of Object.values(cluster.workers)) { if (worker.state === 'online' || worker.state === 'listening') { process._debugProcess(worker.process.pid); } else { @@ -227,11 +224,10 @@ cluster.disconnect = function(cb) { if (workers.length === 0) { process.nextTick(() => intercom.emit('disconnect')); } else { - for (var key in workers) { - key = workers[key]; - - if (cluster.workers[key].isConnected()) - cluster.workers[key].disconnect(); + for (const worker of Object.values(cluster.workers)) { + if (worker.isConnected()) { + worker.disconnect(); + } } } |