Skip to content
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

feat(compat): Add lastIndexOf function to es-toolkit/compat #856

Merged
merged 7 commits into from
Dec 1, 2024

Conversation

evan-moon
Copy link
Member

@evan-moon evan-moon commented Dec 1, 2024

This PR introduces the lastIndexOf function to es-toolkit/compat. #91

This function similarly to Array.prototype.lastIndexOf but includes support for NaN handling, aligning its behavior with Lodash's implementation.

The implementation has been tested using the test cases from the Lodash repository's lastIndexOf. However, in the context of es-toolkit/compat, the fromIndex parameter only accepts number or undefined types.
As a result, test cases related to falsy values for fromIndex have been omitted.

Benchmark

Test with an array of length 1,000,000.

스크린샷 2024-12-01 오후 2 10 47

Coverage

These test cases were written with reference to the test cases of Lodash's lastIndexOf function.

스크린샷 2024-12-01 오후 2 11 24

and Instanbul's coverage report says all green.

스크린샷 2024-12-01 오후 2 11 30

@evan-moon evan-moon requested a review from raon0211 as a code owner December 1, 2024 05:23
@evan-moon evan-moon self-assigned this Dec 1, 2024
Copy link

vercel bot commented Dec 1, 2024

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

Name Status Preview Comments Updated (UTC)
es-toolkit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 1, 2024 7:08am

raon0211
raon0211 previously approved these changes Dec 1, 2024
Copy link
Collaborator

@raon0211 raon0211 left a comment

Choose a reason for hiding this comment

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

Thanks!

raon0211
raon0211 previously approved these changes Dec 1, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.61%. Comparing base (d42fc96) to head (037f758).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #856      +/-   ##
==========================================
- Coverage   99.64%   99.61%   -0.04%     
==========================================
  Files         317      318       +1     
  Lines        2826     2838      +12     
  Branches      842      848       +6     
==========================================
+ Hits         2816     2827      +11     
- Misses         10       11       +1     

@raon0211 raon0211 merged commit 9a6a7db into toss:main Dec 1, 2024
8 checks passed
@evan-moon evan-moon deleted the feat/lastIndexOf branch December 4, 2024 11:48
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