summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsagirk <sagir.khan@gmail.com>2018-11-19 14:50:15 +0530
committerGireesh Punathil <gpunathi@in.ibm.com>2018-11-22 14:48:39 +0530
commita67b22a21888ec5812b1c3e8ef75e78db49ac9e1 (patch)
treec791521d8a90c3ba23bfee672a177de77fdc850b
parent4d35fa7d076d4815b7360c1095c7ad836e8f8fdb (diff)
downloadandroid-node-v8-a67b22a21888ec5812b1c3e8ef75e78db49ac9e1.tar.gz
android-node-v8-a67b22a21888ec5812b1c3e8ef75e78db49ac9e1.tar.bz2
android-node-v8-a67b22a21888ec5812b1c3e8ef75e78db49ac9e1.zip
test: refactor test to use arrow functions
In `test/parallel/test-cluster-send-deadlock.js`, callbacks use anonymous closure functions. It is safe to replace them with arrow functions since these callbacks don't contain references to `this`, `super` or `arguments`. This results in shorter functions. PR-URL: https://github.com/nodejs/node/pull/24479 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
-rw-r--r--test/parallel/test-cluster-send-deadlock.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/test/parallel/test-cluster-send-deadlock.js b/test/parallel/test-cluster-send-deadlock.js
index b02837e7fb..b34eb892ad 100644
--- a/test/parallel/test-cluster-send-deadlock.js
+++ b/test/parallel/test-cluster-send-deadlock.js
@@ -30,31 +30,31 @@ const net = require('net');
if (cluster.isMaster) {
const worker = cluster.fork();
- worker.on('exit', function(code, signal) {
+ worker.on('exit', (code, signal) => {
assert.strictEqual(code, 0, `Worker exited with an error code: ${code}`);
assert(!signal, `Worker exited by a signal: ${signal}`);
server.close();
});
- const server = net.createServer(function(socket) {
+ const server = net.createServer((socket) => {
worker.send('handle', socket);
});
- server.listen(0, function() {
+ server.listen(0, () => {
worker.send({ message: 'listen', port: server.address().port });
});
} else {
- process.on('message', function(msg, handle) {
+ process.on('message', (msg, handle) => {
if (msg.message && msg.message === 'listen') {
assert(msg.port);
const client1 = net.connect({
host: 'localhost',
port: msg.port
- }, function() {
+ }, () => {
const client2 = net.connect({
host: 'localhost',
port: msg.port
- }, function() {
+ }, () => {
client1.on('close', onclose);
client2.on('close', onclose);
client1.end();
@@ -62,10 +62,10 @@ if (cluster.isMaster) {
});
});
let waiting = 2;
- function onclose() {
+ const onclose = () => {
if (--waiting === 0)
cluster.worker.disconnect();
- }
+ };
} else {
process.send('reply', handle);
}