refactor(json-difference): extract sentinel unwrap helper#95
Merged
lukascivil merged 5 commits intomasterfrom Apr 23, 2026
Merged
refactor(json-difference): extract sentinel unwrap helper#95lukascivil merged 5 commits intomasterfrom
lukascivil merged 5 commits intomasterfrom
Conversation
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.
Objective
The sentinel strings
'@{}'and'@[]'were duplicated across three files (get-edited-paths.ts,get-paths-diff.ts,sanitize-delta.ts). This refactor extracts them into a singleunwrap-sentinelhelper to eliminate the duplication and make future sentinel changes easier to apply consistently.What was done
libs/json-difference/src/helpers/unwrap-sentinel.tswithOBJECT_SENTINEL,ARRAY_SENTINELconstants and anunwrapSentinelfunction that maps sentinel values back to{}/[]unwrapSentinelinlibs/json-difference/src/helpers/unwrap-sentinel.spec.tsget-edited-paths.ts,get-paths-diff.ts, andsanitize-delta.tswith the new helper;sanitize-delta.tsnow preserves the original tuple reference when no sentinel is presentunwrap-sentinelfromlibs/json-difference/src/helpers/index.tstsconfig.spec.jsonreference tolibs/json-difference/tsconfig.jsonfixture/oldJson.json,fixture/newJson.json,fixture/delta.json) and a fixture-based integration test inget-diff.spec.tsthat verifies the full diff output against a known snapshotTest plan
yarn nx test json-difference— all tests should pass including the new fixture testyarn nx lint json-difference— no warnings