Skip to content

Commit 879e60a

Browse files
committed
lib: improve for-loop in master.js
1 parent 8a273f1 commit 879e60a

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lib/internal/cluster/master.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ cluster.setupMaster = function(options) {
8080
if (message.cmd !== 'NODE_DEBUG_ENABLED')
8181
return;
8282

83-
var key;
84-
for (key in cluster.workers) {
85-
const worker = cluster.workers[key];
86-
83+
for (const worker of Object.values(cluster.workers)) {
8784
if (worker.state === 'online' || worker.state === 'listening') {
8885
process._debugProcess(worker.process.pid);
8986
} else {
@@ -227,11 +224,10 @@ cluster.disconnect = function(cb) {
227224
if (workers.length === 0) {
228225
process.nextTick(() => intercom.emit('disconnect'));
229226
} else {
230-
for (var key in workers) {
231-
key = workers[key];
232-
233-
if (cluster.workers[key].isConnected())
234-
cluster.workers[key].disconnect();
227+
for (const worker of Object.values(cluster.workers)) {
228+
if (worker.isConnected()) {
229+
worker.disconnect();
230+
}
235231
}
236232
}
237233

0 commit comments

Comments
 (0)