Skip to content

Conversation

wo-o29
Copy link
Contributor

@wo-o29 wo-o29 commented Oct 9, 2025

Summary

This PR simplifies the find function implementation by removing unnecessary type checks and simplifying array handling logic.

This fix improves test coverage.

Before After
스크린샷 2025-10-10 오전 1 02 32 스크린샷 2025-10-10 오전 1 07 46

There is no test for the case where there is no predicate, so the coverage is not 100%. However, someone else worked on this part, so I did not modify it separately!

Changes

  • Removed unnecessary typeof doesMatch === 'function' check since iteratee() always returns a function
  • Simplified array handling: changed Array.isArray(source) ? source.slice(fromIndex) : Object.values(source).slice(fromIndex) to source.slice(fromIndex) since at that point in the code, source is guaranteed to be an array

Additional

The findLast function also had the same issue and was fixed. This function also did not have a test for the case where there is no predicate, so the coverage is not 100%, but someone else worked on it :) #1450

@Copilot Copilot AI review requested due to automatic review settings October 9, 2025 16:13
Copy link

vercel bot commented Oct 9, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
es-toolkit Ready Ready Preview Comment Oct 9, 2025 4:29pm

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the find function to simplify its logic by removing unnecessary type checks and streamlining array handling. The changes improve code maintainability while preserving functionality.

  • Removed redundant typeof doesMatch === 'function' check since iteratee() always returns a function
  • Simplified array slicing logic by removing conditional check that was no longer needed
  • Improved test coverage as shown in the before/after screenshots

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.90%. Comparing base (21bd853) to head (95338a0).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1453      +/-   ##
==========================================
- Coverage   99.90%   99.90%   -0.01%     
==========================================
  Files         468      468              
  Lines        4439     4437       -2     
  Branches     1309     1307       -2     
==========================================
- Hits         4435     4433       -2     
  Misses          4        4              
🚀 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.

@wo-o29 wo-o29 changed the title refactor(find): simplify logic by removing unnecessary checks refactor(find, findLast): simplify logic by removing unnecessary checks Oct 9, 2025
@wo-o29 wo-o29 changed the title refactor(find, findLast): simplify logic by removing unnecessary checks fix(find, findLast): simplify logic by removing unnecessary checks Oct 9, 2025
@sukvvon
Copy link
Contributor

sukvvon commented Oct 9, 2025

Hello! @wo-o29 I've created a PR(#1454) for what you were concerned about! 😄

@wo-o29
Copy link
Contributor Author

wo-o29 commented Oct 10, 2025

Hello! @wo-o29 I've created a PR(#1454) for what you were concerned about! 😄

Confirmed, thank you!👍

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