GeezerVison is showing github.com — doc: use arrow function for anonymous callbacks · nodejs/node@a1a393b
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: doc/api/async_hooks.md +3-4Lines changed: 3 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -479,13 +479,12 @@ The ID returned from `executionAsyncId()` is related to execution timing, not |
479 | 479 | causality (which is covered by `triggerAsyncId()`): |
480 | 480 |
|
481 | 481 | ```js |
482 | | -const server = net.createServer(function onConnection(conn) { |
| 482 | +const server = net.createServer((conn) => { |
483 | 483 | // Returns the ID of the server, not of the new connection, because the |
484 | | - // onConnection callback runs in the execution scope of the server's |
485 | | - // MakeCallback(). |
| 484 | + // callback runs in the execution scope of the server's MakeCallback(). |
486 | 485 | async_hooks.executionAsyncId(); |
487 | 486 |
|
488 | | -}).listen(port, function onListening() { |
| 487 | +}).listen(port, () => { |
489 | 488 | // Returns the ID of a TickObject (i.e. process.nextTick()) because all |
490 | 489 | // callbacks passed to .listen() are wrapped in a nextTick(). |
491 | 490 | async_hooks.executionAsyncId(); |
|