MCPcopy Create free account
hub / github.com/atomicdata-dev/atomic-data-browser / replaceKey

Function replaceKey

lib/src/commit.ts:98–111  ·  view source on GitHub ↗

Replaces a key in a Commit. Ignores it if it's not there

(
  o: Commit | CommitPreSigned,
  oldKey: string,
  newKey: string,
)

Source from the content-addressed store, hash-verified

96
97/** Replaces a key in a Commit. Ignores it if it's not there */
98function replaceKey(
99 o: Commit | CommitPreSigned,
100 oldKey: string,
101 newKey: string,
102) {
103 if (oldKey in o && oldKey !== newKey) {
104 Object.defineProperty(
105 o,
106 newKey,
107 Object.getOwnPropertyDescriptor(o, oldKey),
108 );
109 delete o[oldKey];
110 }
111}
112
113/**
114 * Takes a commit and serializes it deterministically (canonicilaization). Is

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected