Skip to content

Commit e8c0fce

Browse files
codegaganrvagg
authored andcommitted
test: replace closure functions with arrow functions
PR-URL: #24522 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 2c8c7b8 commit e8c0fce

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

test/parallel/test-http-write-callbacks.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let clientEndCb = false;
3333
let clientIncoming = '';
3434
const clientIncomingExpect = 'asdffoobar';
3535

36-
process.on('exit', function() {
36+
process.on('exit', () => {
3737
assert(serverEndCb);
3838
assert.strictEqual(serverIncoming, serverIncomingExpect);
3939
assert(clientEndCb);
@@ -42,22 +42,22 @@ process.on('exit', function() {
4242
});
4343

4444
// Verify that we get a callback when we do res.write(..., cb)
45-
const server = http.createServer(function(req, res) {
45+
const server = http.createServer((req, res) => {
4646
res.statusCode = 400;
4747
res.end('Bad Request.\nMust send Expect:100-continue\n');
4848
});
4949

50-
server.on('checkContinue', function(req, res) {
50+
server.on('checkContinue', (req, res) => {
5151
server.close();
5252
assert.strictEqual(req.method, 'PUT');
53-
res.writeContinue(function() {
53+
res.writeContinue(() => {
5454
// continue has been written
55-
req.on('end', function() {
56-
res.write('asdf', function(er) {
55+
req.on('end', () => {
56+
res.write('asdf', (er) => {
5757
assert.ifError(er);
58-
res.write('foo', 'ascii', function(er) {
58+
res.write('foo', 'ascii', (er) => {
5959
assert.ifError(er);
60-
res.end(Buffer.from('bar'), 'buffer', function(er) {
60+
res.end(Buffer.from('bar'), 'buffer', (er) => {
6161
serverEndCb = true;
6262
});
6363
});
@@ -66,7 +66,7 @@ server.on('checkContinue', function(req, res) {
6666
});
6767

6868
req.setEncoding('ascii');
69-
req.on('data', function(c) {
69+
req.on('data', (c) => {
7070
serverIncoming += c;
7171
});
7272
});
@@ -77,24 +77,24 @@ server.listen(0, function() {
7777
method: 'PUT',
7878
headers: { 'expect': '100-continue' }
7979
});
80-
req.on('continue', function() {
80+
req.on('continue', () => {
8181
// ok, good to go.
82-
req.write('YmF6', 'base64', function(er) {
82+
req.write('YmF6', 'base64', (er) => {
8383
assert.ifError(er);
84-
req.write(Buffer.from('quux'), function(er) {
84+
req.write(Buffer.from('quux'), (er) => {
8585
assert.ifError(er);
86-
req.end('626c657267', 'hex', function(er) {
86+
req.end('626c657267', 'hex', (er) => {
8787
assert.ifError(er);
8888
clientEndCb = true;
8989
});
9090
});
9191
});
9292
});
93-
req.on('response', function(res) {
93+
req.on('response', (res) => {
9494
// this should not come until after the end is flushed out
9595
assert(clientEndCb);
9696
res.setEncoding('ascii');
97-
res.on('data', function(c) {
97+
res.on('data', (c) => {
9898
clientIncoming += c;
9999
});
100100
});

0 commit comments

Comments
 (0)