Skip to content

Commit 9e6c983

Browse files
M1chaelChenjasnell
authored andcommitted
test: refactor functions to es6
PR-URL: #23510 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent b06113a commit 9e6c983

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

test/parallel/test-cluster-setup-master-multiple.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@ assert(cluster.isMaster);
3030
// makes that unnecessary. This is to make the test less fragile if the
3131
// implementation ever changes such that cluster.settings is mutated instead of
3232
// replaced.
33-
function cheapClone(obj) {
34-
return JSON.parse(JSON.stringify(obj));
35-
}
33+
const cheapClone = (obj) => JSON.parse(JSON.stringify(obj));
3634

3735
const configs = [];
3836

3937
// Capture changes
40-
cluster.on('setup', function() {
38+
cluster.on('setup', () => {
4139
console.log('"setup" emitted', cluster.settings);
4240
configs.push(cheapClone(cluster.settings));
4341
});
@@ -48,7 +46,7 @@ const execs = [
4846
'node-next-3',
4947
];
5048

51-
process.on('exit', function assertTests() {
49+
process.on('exit', () => {
5250
// Tests that "setup" is emitted for every call to setupMaster
5351
assert.strictEqual(configs.length, execs.length);
5452

@@ -58,14 +56,14 @@ process.on('exit', function assertTests() {
5856
});
5957

6058
// Make changes to cluster settings
61-
execs.forEach(function(v, i) {
62-
setTimeout(function() {
59+
execs.forEach((v, i) => {
60+
setTimeout(() => {
6361
cluster.setupMaster({ exec: v });
6462
}, i * 100);
6563
});
6664

6765
// cluster emits 'setup' asynchronously, so we must stay alive long
6866
// enough for that to happen
69-
setTimeout(function() {
67+
setTimeout(() => {
7068
console.log('cluster setup complete');
7169
}, (execs.length + 1) * 100);

0 commit comments

Comments
 (0)