Title: Suggestion: Re-purpose `events.listenerCount()` as agnostic function over EventEmitters/EventTargets · Issue #60212 · nodejs/node · GitHub
Open Graph Title: Suggestion: Re-purpose `events.listenerCount()` as agnostic function over EventEmitters/EventTargets · Issue #60212 · nodejs/node
X Title: Suggestion: Re-purpose `events.listenerCount()` as agnostic function over EventEmitters/EventTargets · Issue #60212 · nodejs/node
Description: There are many top-level functions in node:events that mirror their equivalents on the EventEmitter prototype, but also accept EventTarget arguments. (getEventListeners(), getMaxListeners(), etc.) events.listenerCount() was previously de...
Open Graph Description: There are many top-level functions in node:events that mirror their equivalents on the EventEmitter prototype, but also accept EventTarget arguments. (getEventListeners(), getMaxListeners(), etc.) ...
X Description: There are many top-level functions in node:events that mirror their equivalents on the EventEmitter prototype, but also accept EventTarget arguments. (getEventListeners(), getMaxListeners(), etc.) ...
Opengraph URL: https://github.com/nodejs/node/issues/60212
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Suggestion: Re-purpose `events.listenerCount()` as agnostic function over EventEmitters/EventTargets","articleBody":"There are many top-level functions in `node:events` that mirror their equivalents on the EventEmitter prototype, but also accept EventTarget arguments. (`getEventListeners()`, `getMaxListeners()`, etc.)\n\n`events.listenerCount()` was previously deprecated on the basis of duplicating the functionality of `EventEmitter.prototype.listenerCount()`. However, there's no equivalent function on the EventTarget prototype, and it seems like this would be a good candidate to follow the others and become an agnostic utility function.\n\n```js\nconst { listenerCount } = require('events')\n\nconst et = new EventTarget()\net.addEventListener('event', () =\u003e {})\n\nlistenerCount(et, 'event') // 1\n```\n\nAn alternative for this functionality exists via `getEventListeners(...).length`, but since `listenerCount()` already exists (and has an analogue on the EventEmitter prototype that isn't going anywhere), it seems like this would be a low-effort improvement.","author":{"url":"https://github.com/Renegade334","@type":"Person","name":"Renegade334"},"datePublished":"2025-10-11T16:15:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/60212/node/issues/60212"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:dd7a75cb-8a80-f333-5c51-6f04d7b8b457 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B618:1138FF:C8B3B4:1114683:6A4D5904 |
| html-safe-nonce | cbc11155f199be3dc7d69884c2de07117f60d90eb2be880bc37f3d83f64858fc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjE4OjExMzhGRjpDOEIzQjQ6MTExNDY4Mzo2QTRENTkwNCIsInZpc2l0b3JfaWQiOiI2NTUwMDU5MTM1MTgxNjA5MjIwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 8436a4512727fff81e4b0ee58de26edd9f041a7f8a1f133b8333c82f2ccb4af9 |
| hovercard-subject-tag | issue:3506061947 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/60212/issue_layout |
| twitter:image | https://opengraph.githubassets.com/af1126418ea7d6395fcce3612e615fe04b0abd40f0d5eb3367e10522ce7b5548/nodejs/node/issues/60212 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/af1126418ea7d6395fcce3612e615fe04b0abd40f0d5eb3367e10522ce7b5548/nodejs/node/issues/60212 |
| og:image:alt | There are many top-level functions in node:events that mirror their equivalents on the EventEmitter prototype, but also accept EventTarget arguments. (getEventListeners(), getMaxListeners(), etc.) ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Renegade334 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2a1443ff9733a3016431263ea73c93d8fe00c195eb4a7670ac30e7848f045441 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f3bdd3157ea1f0fd738d408eceeead721acf1dc3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width