mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
doc: use arrow function for anonymous callbacks
PR-URL: https://github.com/nodejs/node/pull/24606 Reviewed-By: Ron Korving <ron@ronkorving.nl> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
This commit is contained in:
1 parent
d4491a48ba
commit
b65ffd5b1d
1 file changed
+3
-4
@@ -479,13 +479,12 @@ The ID returned from `executionAsyncId()` is related to execution timing, not
|
||||
causality (which is covered by `triggerAsyncId()`):
|
||||
|
||||
```js
|
||||
const server = net.createServer(function onConnection(conn) {
|
||||
const server = net.createServer((conn) => {
|
||||
// Returns the ID of the server, not of the new connection, because the
|
||||
// onConnection callback runs in the execution scope of the server's
|
||||
// MakeCallback().
|
||||
// callback runs in the execution scope of the server's MakeCallback().
|
||||
async_hooks.executionAsyncId();
|
||||
|
||||
}).listen(port, function onListening() {
|
||||
}).listen(port, () => {
|
||||
// Returns the ID of a TickObject (i.e. process.nextTick()) because all
|
||||
// callbacks passed to .listen() are wrapped in a nextTick().
|
||||
async_hooks.executionAsyncId();
|
||||
|
||||
Reference in new issue
Block a user