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 <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
deokjinkim authored and danielleadams committed Apr 5, 2023
1 parent 0ddf73a commit 45fccc9
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 @@ -2314,6 +2314,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 @@ -2375,7 +2389,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 @@ -2389,7 +2403,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 @@ -916,7 +916,7 @@ class NodeEventTarget extends EventTarget {
}

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

0 comments on commit 45fccc9

Please sign in to comment.