From c4f16ddccdc90e654c6f466c49746f4e8ad0d3c6 Mon Sep 17 00:00:00 2001 From: sreepurnajasti Date: Mon, 19 Nov 2018 19:20:11 +0530 Subject: [PATCH] test: replace callback with arrow functions PR-URL: https://github.com/nodejs/node/pull/24490 Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Franziska Hinkelmann Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Ruben Bridgewater --- test/pummel/test-keep-alive.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js index b62d731c7b4006..0fec1ff877b89b 100644 --- a/test/pummel/test-keep-alive.js +++ b/test/pummel/test-keep-alive.js @@ -32,7 +32,7 @@ const http = require('http'); const url = require('url'); const body = 'hello world\n'; -const server = http.createServer(function(req, res) { +const server = http.createServer((req, res) => { res.writeHead(200, { 'Content-Length': body.length, 'Content-Type': 'text/plain' @@ -45,7 +45,7 @@ let keepAliveReqSec = 0; let normalReqSec = 0; -function runAb(opts, callback) { +const runAb = (opts, callback) => { const args = [ '-c', opts.concurrent || 100, '-t', opts.threads || 2, @@ -66,11 +66,9 @@ function runAb(opts, callback) { let stdout; - child.stdout.on('data', function(data) { - stdout += data; - }); + child.stdout.on('data', (data) => stdout += data); - child.on('close', function(code, signal) { + child.on('close', (code, signal) => { if (code) { console.error(code, signal); process.exit(code); @@ -90,20 +88,20 @@ function runAb(opts, callback) { callback(reqSec, keepAliveRequests); }); -} +}; server.listen(common.PORT, () => { runAb({ keepalive: true }, (reqSec) => { keepAliveReqSec = reqSec; - runAb({ keepalive: false }, function(reqSec) { + runAb({ keepalive: false }, (reqSec) => { normalReqSec = reqSec; server.close(); }); }); }); -process.on('exit', function() { +process.on('exit', () => { assert.strictEqual( normalReqSec > 50, true,