From 9e6c983884a976f95a03a516422c84987b74d302 Mon Sep 17 00:00:00 2001 From: Michael Chen Date: Fri, 12 Oct 2018 10:22:52 -0700 Subject: [PATCH] test: refactor functions to es6 PR-URL: https://github.com/nodejs/node/pull/23510 Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat --- .../parallel/test-cluster-setup-master-multiple.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-cluster-setup-master-multiple.js b/test/parallel/test-cluster-setup-master-multiple.js index 2a6341ea56c3c5..b33acccd411a0a 100644 --- a/test/parallel/test-cluster-setup-master-multiple.js +++ b/test/parallel/test-cluster-setup-master-multiple.js @@ -30,14 +30,12 @@ assert(cluster.isMaster); // makes that unnecessary. This is to make the test less fragile if the // implementation ever changes such that cluster.settings is mutated instead of // replaced. -function cheapClone(obj) { - return JSON.parse(JSON.stringify(obj)); -} +const cheapClone = (obj) => JSON.parse(JSON.stringify(obj)); const configs = []; // Capture changes -cluster.on('setup', function() { +cluster.on('setup', () => { console.log('"setup" emitted', cluster.settings); configs.push(cheapClone(cluster.settings)); }); @@ -48,7 +46,7 @@ const execs = [ 'node-next-3', ]; -process.on('exit', function assertTests() { +process.on('exit', () => { // Tests that "setup" is emitted for every call to setupMaster assert.strictEqual(configs.length, execs.length); @@ -58,14 +56,14 @@ process.on('exit', function assertTests() { }); // Make changes to cluster settings -execs.forEach(function(v, i) { - setTimeout(function() { +execs.forEach((v, i) => { + setTimeout(() => { cluster.setupMaster({ exec: v }); }, i * 100); }); // cluster emits 'setup' asynchronously, so we must stay alive long // enough for that to happen -setTimeout(function() { +setTimeout(() => { console.log('cluster setup complete'); }, (execs.length + 1) * 100);