Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add emit to NodeEventTarget #46356

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -935,7 +935,7 @@ class NodeEventTarget extends EventTarget {
}

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