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: fix mismatched arguments of NodeEventTarget #45678

Merged
merged 2 commits into from Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 35 additions & 16 deletions doc/api/events.md
Expand Up @@ -1645,9 +1645,8 @@ and cannot be used in place of an `EventEmitter` in most cases.
ignored.
2. The `NodeEventTarget` does not emulate the full `EventEmitter` API.
Specifically the `prependListener()`, `prependOnceListener()`,
`rawListeners()`, `setMaxListeners()`, `getMaxListeners()`, and
`errorMonitor` APIs are not emulated. The `'newListener'` and
`'removeListener'` events will also not be emitted.
`rawListeners()`, and `errorMonitor` APIs are not emulated.
The `'newListener'` and `'removeListener'` events will also not be emitted.
3. The `NodeEventTarget` does not implement any special default behavior
for events with type `'error'`.
4. The `NodeEventTarget` supports `EventListener` objects as well as
Expand Down Expand Up @@ -2027,7 +2026,7 @@ added: v14.5.0
The `NodeEventTarget` is a Node.js-specific extension to `EventTarget`
that emulates a subset of the `EventEmitter` API.

#### `nodeEventTarget.addListener(type, listener[, options])`
#### `nodeEventTarget.addListener(type, listener)`

<!-- YAML
added: v14.5.0
Expand All @@ -2037,9 +2036,6 @@ added: v14.5.0

* `listener` {Function|EventListener}

* `options` {Object}
* `once` {boolean}

* Returns: {EventTarget} this

Node.js-specific extension to the `EventTarget` class that emulates the
Expand Down Expand Up @@ -2071,7 +2067,29 @@ added: v14.5.0
Node.js-specific extension to the `EventTarget` class that returns the number
of event listeners registered for the `type`.

#### `nodeEventTarget.off(type, listener)`
#### `nodeEventTarget.setMaxListeners(n)`

<!-- YAML
added: v14.5.0
-->

* `n` {number}

Node.js-specific extension to the `EventTarget` class that sets the number
of max event listeners as `n`.

#### `nodeEventTarget.getMaxListeners()`

<!-- YAML
added: v14.5.0
-->

* Returns: {number}

Node.js-specific extension to the `EventTarget` class that returns the number
of max event listeners.
Comment on lines +2070 to +2090
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would need to update this list as well:

node/doc/api/events.md

Lines 1646 to 1650 in 016abb6

2. The `NodeEventTarget` does not emulate the full `EventEmitter` API.
Specifically the `prependListener()`, `prependOnceListener()`,
`rawListeners()`, `setMaxListeners()`, `getMaxListeners()`, and
`errorMonitor` APIs are not emulated. The `'newListener'` and
`'removeListener'` events will also not be emitted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated list of unsupported function in NodeEventTarget. Thank you for comment.


#### `nodeEventTarget.off(type, listener[, options])`

<!-- YAML
added: v14.5.0
Expand All @@ -2081,11 +2099,14 @@ added: v14.5.0

* `listener` {Function|EventListener}

* `options` {Object}
* `capture` {boolean}

* Returns: {EventTarget} this

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

#### `nodeEventTarget.on(type, listener[, options])`
#### `nodeEventTarget.on(type, listener)`

<!-- YAML
added: v14.5.0
Expand All @@ -2095,14 +2116,11 @@ added: v14.5.0

* `listener` {Function|EventListener}

* `options` {Object}
* `once` {boolean}

* Returns: {EventTarget} this

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

#### `nodeEventTarget.once(type, listener[, options])`
#### `nodeEventTarget.once(type, listener)`

<!-- YAML
added: v14.5.0
Expand All @@ -2112,8 +2130,6 @@ added: v14.5.0

* `listener` {Function|EventListener}

* `options` {Object}

* Returns: {EventTarget} this

Node.js-specific extension to the `EventTarget` class that adds a `once`
Expand All @@ -2134,7 +2150,7 @@ Node.js-specific extension to the `EventTarget` class. If `type` is specified,
removes all registered listeners for `type`, otherwise removes all registered
listeners.

#### `nodeEventTarget.removeListener(type, listener)`
#### `nodeEventTarget.removeListener(type, listener[, options])`

<!-- YAML
added: v14.5.0
Expand All @@ -2144,6 +2160,9 @@ added: v14.5.0

* `listener` {Function|EventListener}

* `options` {Object}
* `capture` {boolean}

* Returns: {EventTarget} this

Node.js-specific extension to the `EventTarget` class that removes the
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/event_target.js
Expand Up @@ -821,7 +821,7 @@ class NodeEventTarget extends EventTarget {
}

/**
* @param {string} [type]
* @param {string} type
* @returns {number}
*/
listenerCount(type) {
Expand Down