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: nodejs/node#35851
  • Loading branch information
deokjinkim committed Jan 26, 2023
1 parent f470625 commit 81a7ffe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions doc/api/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -2334,6 +2334,22 @@ 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 +2411,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 +2425,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 @@ -935,7 +935,7 @@ class NodeEventTarget extends EventTarget {
}

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

0 comments on commit 81a7ffe

Please sign in to comment.