From 81a7ffe88c127885085cf1da78993d3ecf414648 Mon Sep 17 00:00:00 2001 From: Deokjin Kim Date: Thu, 26 Jan 2023 12:13:54 +0900 Subject: [PATCH 1/2] doc: add emit to NodeEventTarget NodeEventTarget.emit() is not described in document. Plus, make type parameter of removeAllListeners as optional. Refs: https://github.com/nodejs/node/pull/35851 --- doc/api/events.md | 20 ++++++++++++++++++-- lib/internal/event_target.js | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/doc/api/events.md b/doc/api/events.md index 5f64fa1dec2a7a..c8760f8d3d19c4 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -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)` + + + +* `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()` * `type` {string} - * `arg` {any} - * Returns: {boolean} `true` if event listeners registered for the `type` exist, otherwise `false`.