Deep equality with a set depth
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 112
- Forks
- 45
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 1
Description
Is it possible to limit the deep equality comparison to a certain depth?
For example:
const a = {
foo: {
bar: {
baz: "qux"
}
}
}
const b = {
foo: { // compared deeply
bar: { // compared by identity (===)
baz: "qux"
}
}
}
// this passes, since 'a' and 'b' are structurally equal
expect(a).to.deep.equal(b);
// this would fail, since the 'bar' object would be compared by identity
expect(a).to.deep.depth(1).equal(b);
In my real-world scenario the bar object would of course be a lot more complicated. Comparing these by identity is more than sufficient, and deep-equality even runs into issues due to circular references.
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 by reading the deep-equality API and implementation in the repository, then compare the requested depth behavior with the existing equality semantics. Define how depth 1 treats nested objects and how circular references are handled, and add tests covering the example before considering the work done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100