Skip to content

Commit c4f16dd

Browse files
sreepurnajastirvagg
authored andcommitted
test: replace callback with arrow functions
PR-URL: #24490 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
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‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const http = require('http');
3232
consturl=require('url');
3333

3434
constbody='hello world\n';
35-
constserver=http.createServer(function(req,res){
35+
constserver=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
letnormalReqSec=0;
4646

4747

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

6767
letstdout;
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)