Skip to content

Commit c4f16dd

Browse files
sreepurnajastirvagg
authored andcommitted
test: replace callback with arrow functions
PR-URL: #24490 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 4da44ad commit c4f16dd

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

test/pummel/test-keep-alive.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const http = require('http');
3232
const url = require('url');
3333

3434
const body = 'hello world\n';
35-
const server = http.createServer(function(req, res) {
35+
const server = http.createServer((req, res) => {
3636
res.writeHead(200, {
3737
'Content-Length': body.length,
3838
'Content-Type': 'text/plain'
@@ -45,7 +45,7 @@ let keepAliveReqSec = 0;
4545
let normalReqSec = 0;
4646

4747

48-
function runAb(opts, callback) {
48+
const runAb = (opts, callback) => {
4949
const args = [
5050
'-c', opts.concurrent || 100,
5151
'-t', opts.threads || 2,
@@ -66,11 +66,9 @@ function runAb(opts, callback) {
6666

6767
let stdout;
6868

69-
child.stdout.on('data', function(data) {
70-
stdout += data;
71-
});
69+
child.stdout.on('data', (data) => stdout += data);
7270

73-
child.on('close', function(code, signal) {
71+
child.on('close', (code, signal) => {
7472
if (code) {
7573
console.error(code, signal);
7674
process.exit(code);
@@ -90,20 +88,20 @@ function runAb(opts, callback) {
9088

9189
callback(reqSec, keepAliveRequests);
9290
});
93-
}
91+
};
9492

9593
server.listen(common.PORT, () => {
9694
runAb({ keepalive: true }, (reqSec) => {
9795
keepAliveReqSec = reqSec;
9896

99-
runAb({ keepalive: false }, function(reqSec) {
97+
runAb({ keepalive: false }, (reqSec) => {
10098
normalReqSec = reqSec;
10199
server.close();
102100
});
103101
});
104102
});
105103

106-
process.on('exit', function() {
104+
process.on('exit', () => {
107105
assert.strictEqual(
108106
normalReqSec > 50,
109107
true,

0 commit comments

Comments
 (0)