toss / es-toolkit

A modern JavaScript utility library that's 2-3 times faster and up to 97% smaller—a major upgrade to lodash.
https://es-toolkit.slash.page
Other
7.1k stars 329 forks source link

perf(compat/array): Improve performance of various array functions in `compat` #796

Closed filipsobol closed 2 weeks ago

filipsobol commented 2 weeks ago

Various compatibility array functions are slow when handling large arrays, which is largely caused by unnecessary Array.from() calls. This PR adds a check, so Array.from() is only called when necessary.

Below are performance improvements for the head function. Results for other methods are similar.

Before: Before


After: After

vercel[bot] commented 2 weeks ago

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 Nov 7, 2024 9:22am
codecov-commenter commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.15%. Comparing base (67ea6bf) to head (3a6428f). Report is 2 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/toss/es-toolkit/pull/796/graphs/tree.svg?width=650&height=150&src=pr&token=8N5S3AR3C7&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss)](https://app.codecov.io/gh/toss/es-toolkit/pull/796?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss) ```diff @@ Coverage Diff @@ ## main #796 +/- ## ======================================= Coverage 99.14% 99.15% ======================================= Files 304 304 Lines 2689 2715 +26 Branches 786 799 +13 ======================================= + Hits 2666 2692 +26 Misses 22 22 Partials 1 1 ```