-
Notifications
You must be signed in to change notification settings - Fork 67
refactor: Replace map with forEach in event emitter #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- The emit method in emitter.ts was using map() but not using the returned array. - This commit changes it to forEach() which is semantically more appropriate for operations that don't require a transformed array result.
🦋 Changeset detectedLatest commit: d2316cd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
jungpaeng
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #158 +/- ##
=======================================
Coverage 93.87% 93.87%
=======================================
Files 12 12
Lines 343 343
Branches 85 85
=======================================
Hits 322 322
Misses 20 20
Partials 1 1
🚀 New features to boost your workflow:
|
Description
This PR replaces the use of
map()withforEach()in the emit method of the event emitter utility. Since the original code doesn't use the array returned bymap(), usingforEach()better communicates the intent of the code and prevents unnecessary array creation.Related Issue: N/A
Changes
map()toforEach()in the emit method of the emitter.ts filemap()Motivation and Context
When performing operations on array elements where you don't need the resulting array,
forEach()is the more appropriate method to use. This change better communicates the intent of the code, avoids creating unnecessary arrays, and follows JavaScript best practices.How Has This Been Tested?
map()vsforEach()behavior to confirm identical functionalityTypes of changes
Checklist