Conversation
This branch has not been deployed
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.
diff(a, clone(a))returns a non-empty delta when an array contains an object (or array) next to any repeated primitive.The input from #420 (
{ A: [["B"], 1, "C", 2, "C"] }) hits the same path.arraysHaveMatchByRef()returns true whenarray1[i] === array2[j]for anyi !== j. For repeated primitives ("a"at two positions) that is always true, somatchByPositionis switched off.matchByPositionis only read for objects inmatchItems, so same-position objects then stop matching and show up as a delete plus an insert. The same thing makes a change inside an object look like a replacement:The fix only counts non-null object values in
arraysHaveMatchByRef(). Detection of shared object references is unchanged, and arrays of primitives behave as before.Tests: two new array examples (identical array with repeated primitives, and a nested change next to repeated primitives). They fail without the change (4 failed, 420 passed) and pass with it.
npx vitest runinpackages/jsondiffpatch: 5 files, 424 tests pass.tsc --noEmitandbiome checkare clean.