feat(isEqual): add isEqual function with its tests and documentation - #102
Merged
Conversation
ASafaeirad
reviewed
Sep 5, 2026
Comment on lines
+133
to
+134
| if (isComparedBefore(a as object, b as object, comparedObjects)) | ||
| return true; |
Member
There was a problem hiding this comment.
I don't get this part.
Why do we return true if they have already been compared?
Contributor
Author
There was a problem hiding this comment.
As we can see in the next line, this function immediately adds the current comparison to the map. So, when it reaches the same comparison twice or more, it means:
- The result of this comparison was
true(because this function would have already exited early if the result wasfalse). - Or the comparison is still in progress at the parent scope. By returning
true, we skip this comparison and let the parent comparison determine the result, while avoiding a circular reference overflowing our call stack.
By the way, I agree that the naming of these functions and "comparedObjects" is kinda misleading. I can think of new names if you want!
AmirabbasJ
self-requested a review
September 5, 2026 10:49
AmirabbasJ
requested changes
Sep 5, 2026
Co-authored-by: Amirabbas <amirabbasjalali82@gmail.com>
ASafaeirad
approved these changes
Sep 6, 2026
AmirabbasJ
approved these changes
Sep 6, 2026
|
馃帀 This PR is included in version 4.24.0 馃帀 The release is available on: Your semantic-release bot 馃摝馃殌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Function Signature
Motivation
isEqual performs a deep equality comparison between two values, recursively comparing nested structures instead of relying on reference equality.
It supports common JavaScript value types including primitives, functions, objects, arrays, dates, regular expressions, maps, sets, and circular references:
Benefits: