From de35ece3dd90e0707aefd35fd7d5ba5db69c6f98 Mon Sep 17 00:00:00 2001 From: "S. Everett Abbott" Date: Fri, 12 Oct 2018 09:56:49 -0700 Subject: [PATCH 1/2] test: update test-cluster-worker-events to use arrow functions.\n --- test/parallel/test-cluster-worker-events.js | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/parallel/test-cluster-worker-events.js b/test/parallel/test-cluster-worker-events.js index 91e716285dc2b8..3b156addedc63f 100644 --- a/test/parallel/test-cluster-worker-events.js +++ b/test/parallel/test-cluster-worker-events.js @@ -30,7 +30,7 @@ if (cluster.isMaster) { const worker = cluster.fork(); - worker.on('exit', function(code) { + worker.on('exit', (code) => { assert.strictEqual(code, OK); process.exit(0); }); @@ -49,31 +49,31 @@ assert(cluster.isWorker); let sawProcess; let sawWorker; -process.on('message', function(m) { - assert(!sawProcess); - sawProcess = true; - check(m); -}); - -cluster.worker.on('message', function(m) { - assert(!sawWorker); - sawWorker = true; - check(m); -}); - const messages = []; -function check(m) { +const check = (m) => { messages.push(m); if (messages.length < 2) return; assert.deepStrictEqual(messages[0], messages[1]); - cluster.worker.once('error', function(e) { + cluster.worker.once('error', (e) => { assert.strictEqual(e, 'HI'); process.exit(OK); }); process.emit('error', 'HI'); -} +}; + +process.on('message', (m) => { + assert(!sawProcess); + sawProcess = true; + check(m); +}); + +cluster.worker.on('message', (m) => { + assert(!sawWorker); + sawWorker = true; + check(m); +}); From e060ca56bf64220f3c643ab2610891420e0a457b Mon Sep 17 00:00:00 2001 From: "S. Everett Abbott" Date: Fri, 12 Oct 2018 10:31:48 -0700 Subject: [PATCH 2/2] test: update test-cluster-worker-events to use arrow functions.\n --- test/parallel/test-cluster-worker-events.js | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/parallel/test-cluster-worker-events.js b/test/parallel/test-cluster-worker-events.js index 91e716285dc2b8..3b156addedc63f 100644 --- a/test/parallel/test-cluster-worker-events.js +++ b/test/parallel/test-cluster-worker-events.js @@ -30,7 +30,7 @@ if (cluster.isMaster) { const worker = cluster.fork(); - worker.on('exit', function(code) { + worker.on('exit', (code) => { assert.strictEqual(code, OK); process.exit(0); }); @@ -49,31 +49,31 @@ assert(cluster.isWorker); let sawProcess; let sawWorker; -process.on('message', function(m) { - assert(!sawProcess); - sawProcess = true; - check(m); -}); - -cluster.worker.on('message', function(m) { - assert(!sawWorker); - sawWorker = true; - check(m); -}); - const messages = []; -function check(m) { +const check = (m) => { messages.push(m); if (messages.length < 2) return; assert.deepStrictEqual(messages[0], messages[1]); - cluster.worker.once('error', function(e) { + cluster.worker.once('error', (e) => { assert.strictEqual(e, 'HI'); process.exit(OK); }); process.emit('error', 'HI'); -} +}; + +process.on('message', (m) => { + assert(!sawProcess); + sawProcess = true; + check(m); +}); + +cluster.worker.on('message', (m) => { + assert(!sawWorker); + sawWorker = true; + check(m); +});