From d245f53db43d86dbd52879dcbb82e8b4ca33af79 Mon Sep 17 00:00:00 2001 From: suman-mitra Date: Mon, 19 Nov 2018 01:52:06 -0800 Subject: [PATCH] test: replace anonymous closure with arrow functions PR-URL: https://github.com/nodejs/node/pull/24481 Reviewed-By: Gireesh Punathil Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Franziska Hinkelmann Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig --- test/pummel/test-net-pause.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/pummel/test-net-pause.js b/test/pummel/test-net-pause.js index ea0e61264e32db..f9ea33dc93c172 100644 --- a/test/pummel/test-net-pause.js +++ b/test/pummel/test-net-pause.js @@ -28,13 +28,13 @@ const N = 200; let recv = ''; let chars_recved = 0; -const server = net.createServer(function(connection) { +const server = net.createServer((connection) => { function write(j) { if (j >= N) { connection.end(); return; } - setTimeout(function() { + setTimeout(() => { connection.write('C'); write(j + 1); }, 10); @@ -42,7 +42,7 @@ const server = net.createServer(function(connection) { write(0); }); -server.on('listening', function() { +server.on('listening', () => { const client = net.createConnection(common.PORT); client.setEncoding('ascii'); client.on('data', function(d) { @@ -50,22 +50,22 @@ server.on('listening', function() { recv += d; }); - setTimeout(function() { + setTimeout(() => { chars_recved = recv.length; console.log(`pause at: ${chars_recved}`); assert.strictEqual(chars_recved > 1, true); client.pause(); - setTimeout(function() { + setTimeout(() => { console.log(`resume at: ${chars_recved}`); assert.strictEqual(chars_recved, recv.length); client.resume(); - setTimeout(function() { + setTimeout(() => { chars_recved = recv.length; console.log(`pause at: ${chars_recved}`); client.pause(); - setTimeout(function() { + setTimeout(() => { console.log(`resume at: ${chars_recved}`); assert.strictEqual(chars_recved, recv.length); client.resume(); @@ -78,14 +78,14 @@ server.on('listening', function() { }, 500); - client.on('end', function() { + client.on('end', () => { server.close(); client.end(); }); }); server.listen(common.PORT); -process.on('exit', function() { +process.on('exit', () => { assert.strictEqual(recv.length, N); console.error('Exit'); });