Skip to content

Commit

Permalink
doc: add emit to NodeEventTarget
Browse files Browse the repository at this point in the history
NodeEventTarget.emit() is not described in document. Plus, make
type parameter of removeAllListeners as optional.

Refs: #35851
PR-URL: #46356
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
  • Loading branch information
deokjinkim authored and targos committed Mar 13, 2023
1 parent e07c9b8 commit dd66c48
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions doc/api/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -2334,6 +2334,20 @@ equivalent `EventEmitter` API. The only difference between `addListener()` and
`addEventListener()` is that `addListener()` will return a reference to the
`EventTarget`.

#### `nodeEventTarget.emit(type, arg)`

<!-- YAML
added: v15.2.0
-->

* `type` {string}
* `arg` {any}
* Returns: {boolean} `true` if event listeners registered for the `type` exist,
otherwise `false`.

Node.js-specific extension to the `EventTarget` class that dispatches the
`arg` to the list of handlers for `type`.

#### `nodeEventTarget.eventNames()`

<!-- YAML
Expand Down Expand Up @@ -2395,7 +2409,7 @@ added: v14.5.0

* Returns: {EventTarget} this

Node.js-specific alias for `eventTarget.removeListener()`.
Node.js-specific alias for `eventTarget.removeEventListener()`.

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

Expand All @@ -2409,7 +2423,7 @@ added: v14.5.0

* Returns: {EventTarget} this

Node.js-specific alias for `eventTarget.addListener()`.
Node.js-specific alias for `eventTarget.addEventListener()`.

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

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/event_target.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ class NodeEventTarget extends EventTarget {
}

/**
* @param {string} type
* @param {string} [type]
* @returns {NodeEventTarget}
*/
removeAllListeners(type) {
Expand Down

0 comments on commit dd66c48

Please sign in to comment.