Skip to content

Commit

Permalink
doc: update output of example in events.getEventListeners
Browse files Browse the repository at this point in the history
Update mismatched output of `events.getEventListeners` example.
Plus, show output using console.log.

PR-URL: #46268
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
deokjinkim authored and ruyadorno committed Jan 31, 2023
1 parent 398a747 commit 7a9af38
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions doc/api/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -1232,13 +1232,13 @@ import { getEventListeners, EventEmitter } from 'node:events';
const ee = new EventEmitter();
const listener = () => console.log('Events are fun');
ee.on('foo', listener);
getEventListeners(ee, 'foo'); // [listener]
console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
}
{
const et = new EventTarget();
const listener = () => console.log('Events are fun');
et.addEventListener('foo', listener);
getEventListeners(et, 'foo'); // [listener]
console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
}
```

Expand All @@ -1249,13 +1249,13 @@ const { getEventListeners, EventEmitter } = require('node:events');
const ee = new EventEmitter();
const listener = () => console.log('Events are fun');
ee.on('foo', listener);
getEventListeners(ee, 'foo'); // [listener]
console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
}
{
const et = new EventTarget();
const listener = () => console.log('Events are fun');
et.addEventListener('foo', listener);
getEventListeners(et, 'foo'); // [listener]
console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
}
```

Expand Down

0 comments on commit 7a9af38

Please sign in to comment.