fix(compartment-mapper): invert keys/values of renames in captureFromMap #2667
+306
−392
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.
This more accurately solves for the use case of
compartmentRenames
, because the main use case demands the record is inverted. We can plainly see this issue incaptureFromMap
's test suite (which this change simplifies).In a future change, branded types could describe the distinction between key and value, which are currently both
string
.This change isolates the duplicated code in
archive-lite.js
andcapture-lite.js
into a new internal module,digest.js
.It provides
digestCompartmentMap()
, which is now consumed by botharchive-lite.js
andcapture-lite.js
.Both
makeArchiveCompartmentMap()
andcaptureFromMap()
now pass new properties fromdigestCompartmentMap()
through to their consumers:newToOldCompartmentMap
andoldToNewCompartmentMap
.The
compartmentRenames
property is now soft-deprecated (since its naming is ambiguous). The same property is nownewToOldCompartmentMap
;compartmentRenames
should eventually be removed.Note: The duplicated code drifted slightly in
archive-lite.js
; see e3b310d. These changes were kept and put intodigest.js
.