From b98a2aa37d4a729aaf3fce2f50d67d39e61d7571 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 --- 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'); });