Skip to content

Fix #590. Return original object from diffApply - #597

Open
cpruijsen wants to merge 1 commit into
angus-c:masterfrom
cpruijsen:fix/issue-590
Open

cpruijsen wants to merge 1 commit into
angus-c:masterfrom
cpruijsen:fix/issue-590

Conversation

@cpruijsen

Copy link
Copy Markdown

diffApply now returns the original object instead of the last nested node the path walk stopped on. {a:[1,2,3,4,5]} plus the issue's patch already mutated the root to {a:[1,2,5]}; the return value was [1,2,5]. Returning the original object matches the declared return type T. In-place mutation is unchanged.

An empty patch used to return undefined because var subObject was never assigned. Empty patches now return the original object too.

The change always returns the original root obj. The alternatives are keeping the last walked subObject, or special-casing diff.length === 0 so empty patches still return undefined. The issue, the types (: T), and the README all treat the root as the subject. Nested-node and undefined returns were not a documented contract. Can special-case empty diffs if that undefined is load-bearing.

Fixes #590

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

diffApply array bug

1 participant