GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: fix EventEmitter examples · nodejs/node@6c4e697

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • events.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/events.md‎

Copy file name to clipboardExpand all lines: doc/api/events.md
+3-1Lines changed: 3 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ but important side effect: any *additional* listeners registered to the same
268268
listener that is in the process of being added.
269269

270270
```js
271+
class MyEmitter extends EventEmitter {}
272+
271273
const myEmitter = new MyEmitter();
272274
// Only do this once so we don't loop forever
273275
myEmitter.once('newListener', (event, listener) => {
@@ -319,7 +321,7 @@ A class method that returns the number of listeners for the given `eventName`
319321
registered on the given `emitter`.
320322

321323
```js
322-
const myEmitter = new MyEmitter();
324+
const myEmitter = new EventEmitter();
323325
myEmitter.on('event', () => {});
324326
myEmitter.on('event', () => {});
325327
console.log(EventEmitter.listenerCount(myEmitter, 'event'));

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.