Conversation
Signed-off-by: Samppa Saarela <samppa.saarela@iki.fi>
Old Diff was designed primarily for change detection but used also internally for patching. While path/value "Changes" can be sent over line and applied, they are not very good for that (i.e. result in unnecessary large payloads). While deletions from the head of an array, with this new DiffNode, still result in a large diff/patch, this feature addresses how new object/array values are handled: `DiffNode.patch` contains the new value as-is in case the old value is missing (or it's type has changed). Also deleted object values will not be "exploaded" into path/value -deletions. For example
```ts
const a = {};
const b = { nested: { foo: 'bar' } }
new DiffNode({ oldValue: a, newValue: b }).patch
// => [ { path: '$.nested', value: { foo: 'bar' } } ]
new DiffNode({ oldValue: b, newValue: a }).patch
// => [ { path: '$.nested' } ]
```
`DiffNode.patch` can be used to patch objects using `Path.set` just like the results of the `Diff.changeset`.
Signed-off-by: Samppa Saarela <samppa.saarela@iki.fi>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #142 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 20 21 +1
Lines 3486 3639 +153
Branches 705 746 +41
==========================================
+ Hits 3486 3639 +153
🚀 New features to boost your workflow:
|
NOTE: This commit introduces a slight alteration to the result of `VersionInfo.paths` for a case where there is no previous version or it's type has changed significantly and includeObjects is true: the root object is also included. This makes sense and fixes an oversight of not including it in the first place. Signed-off-by: Samppa Saarela <samppa.saarela@iki.fi>
Signed-off-by: Samppa Saarela <samppa.saarela@iki.fi>
mlison
approved these changes
Nov 28, 2025
mlison
left a comment
There was a problem hiding this comment.
LGTM, small comments but ultimately inconsequential
Signed-off-by: Samppa Saarela <samppa.saarela@iki.fi>
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.
Old Diff was designed primarily for change detection but used also internally for patching. While path/value "Changes" can be sent over line and applied, they are not very good for that (i.e. result in unnecessary large payloads). While deletions from the head of an array, with this new DiffNode, still result in a large diff/patch, this feature addresses how new object/array values are handled:
DiffNode.patchcontains the new value as-is in case the old value is missing (or it's type has changed). Also deleted object values will not be "exploaded" into path/value -deletions. For exampleDiffNode.patchcan be used to patch objects usingPath.setjust like the results of theDiff.changeset.