Skip to content

Conversation

@jiji-hoon96
Copy link
Contributor

Description

This PR replaces the use of map() with forEach() in the emit method of the event emitter utility. Since the original code doesn't use the array returned by map(), using forEach() better communicates the intent of the code and prevents unnecessary array creation.

Related Issue: N/A

Changes

  • Changed map() to forEach() in the emit method of the emitter.ts file
  • This is a semantic improvement that better communicates the intent of the code
  • Prevents unnecessary array creation since we don't use the return value of map()

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?

  • Verified that all existing tests pass with the changed implementation
  • Created test cases comparing map() vs forEach() behavior to confirm identical functionality
  • Manual testing of overlays to ensure event handling works as expected

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have performed a self-review of my own code.
  • My code follows the project's coding style.
  • My changes generate no new warnings.
  • All existing tests pass locally with my changes.

- 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.
@jiji-hoon96 jiji-hoon96 requested a review from jungpaeng as a code owner May 7, 2025 08:53
@changeset-bot
Copy link

changeset-bot bot commented May 7, 2025

🦋 Changeset detected

Latest commit: d2316cd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
overlay-kit Patch

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

@vercel
Copy link

vercel bot commented May 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
overlay-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 11, 2025 2:31am

Copy link
Member

@jungpaeng jungpaeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@codecov-commenter
Copy link

codecov-commenter commented May 11, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.87%. Comparing base (14e5fa1) to head (d2316cd).
⚠️ Report is 29 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           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           
Components Coverage Δ
overlay-kit 93.87% <50.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jungpaeng jungpaeng changed the title Refactor: Replace map with forEach in event emitter refactor: Replace map with forEach in event emitter May 11, 2025
@jungpaeng jungpaeng merged commit a6e2f15 into toss:main Jun 11, 2025
9 of 10 checks passed
@github-actions github-actions bot mentioned this pull request Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants