Skip to content

Commit 81a7ffe

Browse files
committed
doc: add emit to NodeEventTarget
NodeEventTarget.emit() is not described in document. Plus, make type parameter of removeAllListeners as optional. Refs: nodejs/node#35851
1 parent f470625 commit 81a7ffe

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

doc/api/events.md

+18-2
Original file line numberDiff line numberDiff line change
@@ -2334,6 +2334,22 @@ equivalent `EventEmitter` API. The only difference between `addListener()` and
23342334
`addEventListener()` is that `addListener()` will return a reference to the
23352335
`EventTarget`.
23362336

2337+
#### `nodeEventTarget.emit(type, arg)`
2338+
2339+
<!-- YAML
2340+
added: v15.2.0
2341+
-->
2342+
2343+
* `type` {string}
2344+
2345+
* `arg` {any}
2346+
2347+
* Returns: {boolean} `true` if event listeners registered for the `type` exist,
2348+
otherwise `false`.
2349+
2350+
Node.js-specific extension to the `EventTarget` class that dispatches the
2351+
`arg` to the list of handlers for `type`.
2352+
23372353
#### `nodeEventTarget.eventNames()`
23382354

23392355
<!-- YAML
@@ -2395,7 +2411,7 @@ added: v14.5.0
23952411

23962412
* Returns: {EventTarget} this
23972413

2398-
Node.js-specific alias for `eventTarget.removeListener()`.
2414+
Node.js-specific alias for `eventTarget.removeEventListener()`.
23992415

24002416
#### `nodeEventTarget.on(type, listener)`
24012417

@@ -2409,7 +2425,7 @@ added: v14.5.0
24092425

24102426
* Returns: {EventTarget} this
24112427

2412-
Node.js-specific alias for `eventTarget.addListener()`.
2428+
Node.js-specific alias for `eventTarget.addEventListener()`.
24132429

24142430
#### `nodeEventTarget.once(type, listener)`
24152431

lib/internal/event_target.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ class NodeEventTarget extends EventTarget {
935935
}
936936

937937
/**
938-
* @param {string} type
938+
* @param {string} [type]
939939
* @returns {NodeEventTarget}
940940
*/
941941
removeAllListeners(type) {

0 commit comments

Comments
 (0)