Skip to content

Conversation

aleclarson
Copy link
Member

@aleclarson aleclarson commented Jun 28, 2025

Summary

Implement the arrayEquals function which checks if two arrays have the same length and items using Object.is for comparison.

Related issue, if any:

https://github.com/orgs/radashi-org/discussions/323

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed
  • Related benchmarks have been added or updated, if needed
  • Release notes in next-minor.md or next-major.md have been added, if needed

Does this PR introduce a breaking change?

No

Bundle impact

Status File Size 1
A src/array/arrayEquals.ts 154

Footnotes

  1. Function size includes the import dependencies of the function.

@aleclarson aleclarson changed the title feat: add arrayEquals function feat: add arrayEquals function Jun 28, 2025
@aleclarson aleclarson added this to the v12.7.0 milestone Jun 28, 2025
@aleclarson aleclarson moved this to In Progress in Radashi Jun 28, 2025
@aleclarson aleclarson added the new feature This PR adds a new function or extends an existing one label Jun 28, 2025
@Minhir
Copy link
Member

Minhir commented Jun 28, 2025

@aleclarson what's the difference with isEqual?

@aleclarson
Copy link
Member Author

aleclarson commented Jun 28, 2025

@aleclarson what's the difference with isEqual?

isEqual does 76,710 ops/sec and arrayEquals does 4,800,000 ops/sec with empty arrays. While we don't have an isEqual benchmark for comparing two non-empty arrays, I guess the difference is around 10x.

300 less bytes too (33% the size)

And personally, I've never been a fan of isEqual. Feels too heavy most of the time.

@aleclarson aleclarson force-pushed the feat/array-equals branch from 37edf3b to d71f8bb Compare July 7, 2025 19:10
@radashi-bot
Copy link

radashi-bot commented Jul 7, 2025

Benchmark Results

Name Current
arrayEquals: equal arrays 489,044.59 ops/sec ±0.12%
arrayEquals: different last element 485,554.59 ops/sec ±0.09%
arrayEquals: different length 4,603,010.4 ops/sec ±0.1%
arrayEquals: empty arrays 4,587,402.48 ops/sec ±0.1%

Performance regressions of 30% or more should be investigated, unless they were anticipated. Smaller regressions may be due to normal variability, as we don't use dedicated CI infrastructure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature This PR adds a new function or extends an existing one
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants