From 9e5a27a9d310ba64289a326777d9a86e4b9a3928 Mon Sep 17 00:00:00 2001 From: Sourav Shaw Date: Fri, 22 May 2020 18:10:14 +0530 Subject: [PATCH] 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 --- doc/api/events.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/api/events.md b/doc/api/events.md index 11e13e6d852ea6..68e23231677fda 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -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'));