Skip to content

Commit 7989d5c

Browse files
HarshithaKPtargos
authored andcommitted
test: changed function to arrow function
Convert callback functions that are anonymous to arrow functions for better readability. Also adjusted the `this` object in places where that was required. PR-URL: #28726 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Masashi Hirano <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent be32bec commit 7989d5c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/parallel/test-http-wget.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,38 +40,38 @@ const http = require('http');
4040
// content-length is not provided, that the connection is in fact
4141
// closed.
4242

43-
const server = http.createServer(function(req, res) {
43+
const server = http.createServer((req, res) => {
4444
res.writeHead(200, { 'Content-Type': 'text/plain' });
4545
res.write('hello ');
4646
res.write('world\n');
4747
res.end();
4848
});
4949
server.listen(0);
5050

51-
server.on('listening', common.mustCall(function() {
52-
const c = net.createConnection(this.address().port);
51+
server.on('listening', common.mustCall(() => {
52+
const c = net.createConnection(server.address().port);
5353
let server_response = '';
5454

5555
c.setEncoding('utf8');
5656

57-
c.on('connect', function() {
57+
c.on('connect', () => {
5858
c.write('GET / HTTP/1.0\r\n' +
5959
'Connection: Keep-Alive\r\n\r\n');
6060
});
6161

62-
c.on('data', function(chunk) {
62+
c.on('data', (chunk) => {
6363
console.log(chunk);
6464
server_response += chunk;
6565
});
6666

67-
c.on('end', common.mustCall(function() {
67+
c.on('end', common.mustCall(() => {
6868
const m = server_response.split('\r\n\r\n');
6969
assert.strictEqual(m[1], 'hello world\n');
7070
console.log('got end');
7171
c.end();
7272
}));
7373

74-
c.on('close', common.mustCall(function() {
74+
c.on('close', common.mustCall(() => {
7575
console.log('got close');
7676
server.close();
7777
}));

0 commit comments

Comments
 (0)