GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: replace anonymous closure with arrow functions · nodejs/node@c45660f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/pummel
    • test-net-pause.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/pummel/test-net-pause.js‎

Copy file name to clipboardExpand all lines: test/pummel/test-net-pause.js
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,44 +28,44 @@ const N = 200;
2828
let recv = '';
2929
let chars_recved = 0;
3030

31-
const server = net.createServer(function(connection) {
31+
const server = net.createServer((connection) => {
3232
function write(j) {
3333
if (j >= N) {
3434
connection.end();
3535
return;
3636
}
37-
setTimeout(function() {
37+
setTimeout(() => {
3838
connection.write('C');
3939
write(j + 1);
4040
}, 10);
4141
}
4242
write(0);
4343
});
4444

45-
server.on('listening', function() {
45+
server.on('listening', () => {
4646
const client = net.createConnection(common.PORT);
4747
client.setEncoding('ascii');
4848
client.on('data', function(d) {
4949
console.log(d);
5050
recv += d;
5151
});
5252

53-
setTimeout(function() {
53+
setTimeout(() => {
5454
chars_recved = recv.length;
5555
console.log(`pause at: ${chars_recved}`);
5656
assert.strictEqual(chars_recved > 1, true);
5757
client.pause();
58-
setTimeout(function() {
58+
setTimeout(() => {
5959
console.log(`resume at: ${chars_recved}`);
6060
assert.strictEqual(chars_recved, recv.length);
6161
client.resume();
6262

63-
setTimeout(function() {
63+
setTimeout(() => {
6464
chars_recved = recv.length;
6565
console.log(`pause at: ${chars_recved}`);
6666
client.pause();
6767

68-
setTimeout(function() {
68+
setTimeout(() => {
6969
console.log(`resume at: ${chars_recved}`);
7070
assert.strictEqual(chars_recved, recv.length);
7171
client.resume();
@@ -78,14 +78,14 @@ server.on('listening', function() {
7878

7979
}, 500);
8080

81-
client.on('end', function() {
81+
client.on('end', () => {
8282
server.close();
8383
client.end();
8484
});
8585
});
8686
server.listen(common.PORT);
8787

88-
process.on('exit', function() {
88+
process.on('exit', () => {
8989
assert.strictEqual(recv.length, N);
9090
console.error('Exit');
9191
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.