Skip to content

Commit

Permalink
doc: fix mismatched arguments of NodeEventTarget
Browse files Browse the repository at this point in the history
Arguments of some APIs are mismatched and 2 APIs are not as
described.

PR-URL: nodejs#45678
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
deokjinkim authored Jan 19, 2023
1 parent 9a50c6d commit b804399
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
51 changes: 35 additions & 16 deletions doc/api/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -1911,9 +1911,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 @@ -2318,7 +2317,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 @@ -2328,9 +2327,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 @@ -2362,7 +2358,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.

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

<!-- YAML
added: v14.5.0
Expand All @@ -2372,11 +2390,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 @@ -2386,14 +2407,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 @@ -2403,8 +2421,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 @@ -2425,7 +2441,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 @@ -2435,6 +2451,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
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ class NodeEventTarget extends EventTarget {
}

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

0 comments on commit b804399

Please sign in to comment.