objectEqual Sorts Keys Before Compare
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 112
- Forks
- 45
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 1
Description
Today, when reserving the objectEqual function in this library while evaluating deep.equal call stacks in a chai test harness, I observed that when comparing objectEqual() from the default branch in extensiveDeepEqualByType) it sorts the keys.
https://github.com/chaijs/deep-eql/blob/04d6da6518f8ddc288638ca42503752028810120/index.js#L418
https://github.com/chaijs/deep-eql/blob/04d6da6518f8ddc288638ca42503752028810120/index.js#L419
Is it not more performant for large objects to just iterate over unsorted properties with something like hasOwnProperty on the rightHandProperty properties? If so, I can make a PR.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in index.js at the objectEqual branch of extensiveDeepEqualByType, especially the lines linked in the issue, and trace how keys are collected and compared. Determine whether the current sorting is necessary for correctness and compare it with the proposed property lookup approach; done means a justified performance change with the existing deep.equal behavior preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing-qa
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100