chaijs / chaijs/deep-eql

Deep equality with a set depth

Open
#64 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.