doc: fix EventEmitter examples

Since the section refers to EventEmitter, instances in the example
should be created of the same class EventEmitter.

PR-URL: https://github.com/nodejs/node/pull/33513
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Sourav Shaw authored and Beth Griggs committed 2020-12-07 18:05:40 +00:00
1 parent 5f0c8142b7
commit 6c4e697f56
1 file changed
+3 -1
+3 -1
View File
@@ -268,6 +268,8 @@ but important side effect: any *additional* listeners registered to the same
listener that is in the process of being added.
```js
class MyEmitter extends EventEmitter {}
const myEmitter = new MyEmitter();
// Only do this once so we don't loop forever
myEmitter.once('newListener', (event, listener) => {
@@ -319,7 +321,7 @@ A class method that returns the number of listeners for the given `eventName`
registered on the given `emitter`.
```js
const myEmitter = new MyEmitter();
const myEmitter = new EventEmitter();
myEmitter.on('event', () => {});
myEmitter.on('event', () => {});
console.log(EventEmitter.listenerCount(myEmitter, 'event'));