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: #45678
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
deokjinkim authored and juanarbol committed Jan 31, 2023
1 parent a87963d commit de2b7a9
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
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 @@ -2298,7 +2297,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 @@ -2308,9 +2307,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 @@ -2342,7 +2338,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 @@ -2352,11 +2370,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 @@ -2366,14 +2387,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 @@ -2383,8 +2401,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 @@ -2405,7 +2421,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 @@ -2415,6 +2431,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 @@ -822,7 +822,7 @@ class NodeEventTarget extends EventTarget {
}

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

0 comments on commit de2b7a9

Please sign in to comment.