Skip to content

Commit 4070152

Browse files
sreepurnajastirvagg
authored andcommitted
test: replace callback with arrow functions
PR-URL: #24541 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
1 parent 0c51fc5 commit 4070152

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

test/pummel/test-net-throttle.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const body = 'C'.repeat(N);
3434

3535
console.log(`start server on port ${common.PORT}`);
3636

37-
const server = net.createServer(function(connection) {
37+
const server = net.createServer((connection) => {
3838
connection.write(body.slice(0, part_N));
3939
connection.write(body.slice(part_N, 2 * part_N));
4040
assert.strictEqual(connection.write(body.slice(2 * part_N, N)), false);
@@ -44,11 +44,11 @@ const server = net.createServer(function(connection) {
4444
connection.end();
4545
});
4646

47-
server.listen(common.PORT, function() {
47+
server.listen(common.PORT, () => {
4848
let paused = false;
4949
const client = net.createConnection(common.PORT);
5050
client.setEncoding('ascii');
51-
client.on('data', function(d) {
51+
client.on('data', (d) => {
5252
chars_recved += d.length;
5353
console.log(`got ${chars_recved}`);
5454
if (!paused) {
@@ -57,7 +57,7 @@ server.listen(common.PORT, function() {
5757
paused = true;
5858
console.log('pause');
5959
const x = chars_recved;
60-
setTimeout(function() {
60+
setTimeout(() => {
6161
assert.strictEqual(chars_recved, x);
6262
client.resume();
6363
console.log('resume');
@@ -66,14 +66,14 @@ server.listen(common.PORT, function() {
6666
}
6767
});
6868

69-
client.on('end', function() {
69+
client.on('end', () => {
7070
server.close();
7171
client.end();
7272
});
7373
});
7474

7575

76-
process.on('exit', function() {
76+
process.on('exit', () => {
7777
assert.strictEqual(chars_recved, N);
7878
assert.strictEqual(npauses > 2, true);
7979
});

0 commit comments

Comments
 (0)