René's URL Explorer Experiment


Title: events: add addDisposableListener method to EventEmitter by jasnell · Pull Request #58453 · nodejs/node · GitHub

Open Graph Title: events: add addDisposableListener method to EventEmitter by jasnell · Pull Request #58453 · nodejs/node

X Title: events: add addDisposableListener method to EventEmitter by jasnell · Pull Request #58453 · nodejs/node

Description: This adds new use(...) and useOnce(...) methods addDisposableListener method to EventEmitter that returns a disposable object that will unregister the event listeners when disposed, along with two changes that use the new apis to demonstrate how it can be used to simplify some cleanup. const ee = new EventEmitter(); { using ds = new DisposableStack(); ds.use(ee.addDisposableListener('foo', () => {}); ds.use(ee.addDisposableListener('bar', () => {}); if (something) ds.use(ee.addDisposableListener('baz', () => {}); } // The event listeners will all be removed automatically when ds is disposed. // We don't need to separately remember to call removeListener/off to cleanup the event listeners

Open Graph Description: This adds new use(...) and useOnce(...) methods addDisposableListener method to EventEmitter that returns a disposable object that will unregister the event listeners when disposed, along with two ...

X Description: This adds new use(...) and useOnce(...) methods addDisposableListener method to EventEmitter that returns a disposable object that will unregister the event listeners when disposed, along with two ...

Opengraph URL: https://github.com/nodejs/node/pull/58453

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/commits/:range(.:format)
route-controllerpull_requests
route-actioncommits
fetch-noncev2:94439838-ae74-2a5d-440e-6ec6669f7f9d
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE89A:DAE6B:3517673:46747A3:6A655319
html-safe-noncee244c13eef12a8f1b7ed1fef5ff024413141a26e5e4ee7dc11a7fb140f06f0a5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODlBOkRBRTZCOjM1MTc2NzM6NDY3NDdBMzo2QTY1NTMxOSIsInZpc2l0b3JfaWQiOiI1NjcwNzk3ODg4NTIyMTEzODE3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac70de2cefa1cceee3c6fb389c64c47d6c15e7bdda4a04f7810fce1b6c5370b732
hovercard-subject-tagpull_request:2542590322
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/commits
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
twitter:imagehttps://avatars.githubusercontent.com/u/439929?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/439929?s=400&v=4
og:image:altThis adds new use(...) and useOnce(...) methods addDisposableListener method to EventEmitter that returns a disposable object that will unregister the event listeners when disposed, along with two ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None52c76df668885aaff23b50bdca1fa1ea44ac9c1553e888ebc70ff1e4daa4625b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release309153364422b3c499922d1a2a6404910a58ed8e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fpull%2F58453%2Fcommits%2Ff4ca9aed2245a89ceda07ae4e5189234bc3e403b
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fpull%2F58453%2Fcommits%2Ff4ca9aed2245a89ceda07ae4e5189234bc3e403b
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fcommits&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
Reloadhttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
Reloadhttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
Please reload this pagehttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
nodejs https://github.com/nodejs
nodehttps://github.com/nodejs/node
Please reload this pagehttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
Notifications https://github.com/login?return_to=%2Fnodejs%2Fnode
Fork 36.1k https://github.com/login?return_to=%2Fnodejs%2Fnode
Star 118k https://github.com/login?return_to=%2Fnodejs%2Fnode
Code https://github.com/nodejs/node
Issues 1.3k https://github.com/nodejs/node/issues
Pull requests 1.1k https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects https://github.com/nodejs/node/projects
Security and quality 0 https://github.com/nodejs/node/security
Insights https://github.com/nodejs/node/pulse
Code https://github.com/nodejs/node
Issues https://github.com/nodejs/node/issues
Pull requests https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects https://github.com/nodejs/node/projects
Security and quality https://github.com/nodejs/node/security
Insights https://github.com/nodejs/node/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fnodejs%2Fnode%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fnodejs%2Fnode%2Fissues%2Fnew%2Fchoose
jasnellhttps://github.com/jasnell
nodejs:mainhttps://github.com/nodejs/node/tree/main
jasnell:jasnell/eventemitter-usinghttps://github.com/jasnell/node/tree/jasnell/eventemitter-using
Conversation 23 https://github.com/nodejs/node/pull/58453
Commits 1 https://github.com/nodejs/node/pull/58453/commits
Checks 0 https://github.com/nodejs/node/pull/58453/checks
Files changed https://github.com/nodejs/node/pull/58453/files
Please reload this pagehttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
events: add addDisposableListener method to EventEmitter https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#top
Show all changes 1 commit https://github.com/nodejs/node/pull/58453/files
f4ca9ae events: Add addDisposableListener method to EventEmitter jasnell May 25, 2025 https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
Clear filters https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
Please reload this pagehttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
Please reload this pagehttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
events.md https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-acab04eff9355fc62738fb601b7d1b1974c0d686c4396971dbab1f0432fbaadf
events.js https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-330bdd22a188135540523f69deb4f9563e03b00a913cd369e1ee84d899f178a9
end-of-stream.js https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-f355a772a51133f54ef288a365ec05a70b9f3f2e0a2f46f5ba2612e31a62f810
harness.js https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-b05fccdd396676d2cafa05396439532ca4ccf77723384065cca8eaac5dec239c
test-events-disposable.js https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-369ebd26657cbbf96dc945e08029340ad733fc677187c023762ab63f124eed0d
Please reload this pagehttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
https://github.com/jasnell
jasnellhttps://github.com/nodejs/node/commits?author=jasnell
doc/api/events.mdhttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-acab04eff9355fc62738fb601b7d1b1974c0d686c4396971dbab1f0432fbaadf
View file https://github.com/jasnell/node/blob/f4ca9aed2245a89ceda07ae4e5189234bc3e403b/doc/api/events.md
Open in desktop https://desktop.github.com
Please reload this pagehttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/58453/commits/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-acab04eff9355fc62738fb601b7d1b1974c0d686c4396971dbab1f0432fbaadf
legendecashttps://github.com/legendecas
Jun 9, 2025https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#r2135702323
Please reload this pagehttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-acab04eff9355fc62738fb601b7d1b1974c0d686c4396971dbab1f0432fbaadf
lib/events.jshttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-330bdd22a188135540523f69deb4f9563e03b00a913cd369e1ee84d899f178a9
View file https://github.com/jasnell/node/blob/f4ca9aed2245a89ceda07ae4e5189234bc3e403b/lib/events.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/58453/commits/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-330bdd22a188135540523f69deb4f9563e03b00a913cd369e1ee84d899f178a9
lib/internal/streams/end-of-stream.jshttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-f355a772a51133f54ef288a365ec05a70b9f3f2e0a2f46f5ba2612e31a62f810
View file https://github.com/jasnell/node/blob/f4ca9aed2245a89ceda07ae4e5189234bc3e403b/lib/internal/streams/end-of-stream.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/58453/commits/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-f355a772a51133f54ef288a365ec05a70b9f3f2e0a2f46f5ba2612e31a62f810
https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-f355a772a51133f54ef288a365ec05a70b9f3f2e0a2f46f5ba2612e31a62f810
https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-f355a772a51133f54ef288a365ec05a70b9f3f2e0a2f46f5ba2612e31a62f810
Please reload this pagehttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-f355a772a51133f54ef288a365ec05a70b9f3f2e0a2f46f5ba2612e31a62f810
https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-f355a772a51133f54ef288a365ec05a70b9f3f2e0a2f46f5ba2612e31a62f810
lib/internal/test_runner/harness.jshttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-b05fccdd396676d2cafa05396439532ca4ccf77723384065cca8eaac5dec239c
View file https://github.com/jasnell/node/blob/f4ca9aed2245a89ceda07ae4e5189234bc3e403b/lib/internal/test_runner/harness.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/58453/commits/{{ revealButtonHref }}
https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-b05fccdd396676d2cafa05396439532ca4ccf77723384065cca8eaac5dec239c
Please reload this pagehttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b
https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-b05fccdd396676d2cafa05396439532ca4ccf77723384065cca8eaac5dec239c
https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-b05fccdd396676d2cafa05396439532ca4ccf77723384065cca8eaac5dec239c
https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-b05fccdd396676d2cafa05396439532ca4ccf77723384065cca8eaac5dec239c
https://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-b05fccdd396676d2cafa05396439532ca4ccf77723384065cca8eaac5dec239c
test/parallel/test-events-disposable.jshttps://github.com/nodejs/node/pull/58453/commits/f4ca9aed2245a89ceda07ae4e5189234bc3e403b#diff-369ebd26657cbbf96dc945e08029340ad733fc677187c023762ab63f124eed0d
View file https://github.com/jasnell/node/blob/f4ca9aed2245a89ceda07ae4e5189234bc3e403b/test/parallel/test-events-disposable.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/nodejs/node/pull/58453/commits/{{ revealButtonHref }}
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.