doc: fix events.once() example using AbortSignal

PR-URL: https://github.com/nodejs/node/pull/55144
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
This commit is contained in:
Ivo Janssen 2024-10-09 00:32:00 -07:00 committed by GitHub
parent 1d38bd1122
commit 755b89772d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1459,8 +1459,7 @@ async function foo(emitter, event, signal) {
}
foo(ee, 'foo', ac.signal);
ac.abort(); // Abort waiting for the event
ee.emit('foo'); // Prints: Waiting for the event was canceled!
ac.abort(); // Prints: Waiting for the event was canceled!
```
```cjs
@ -1483,8 +1482,7 @@ async function foo(emitter, event, signal) {
}
foo(ee, 'foo', ac.signal);
ac.abort(); // Abort waiting for the event
ee.emit('foo'); // Prints: Waiting for the event was canceled!
ac.abort(); // Prints: Waiting for the event was canceled!
```
### Awaiting multiple events emitted on `process.nextTick()`