MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / stableKey

Function stableKey

packages/migration-legacy/src/steps/config.ts:145–154  ·  view source on GitHub ↗

Order-insensitive deep-equality key, so re-ordered tables are not conflicts.

(value: unknown)

Source from the content-addressed store, hash-verified

143
144/** Order-insensitive deep-equality key, so re-ordered tables are not conflicts. */
145function stableKey(value: unknown): string {
146 if (Array.isArray(value)) return `[${value.map(stableKey).join(',')}]`;
147 if (isRecord(value)) {
148 return `{${Object.keys(value)
149 .toSorted()
150 .map((k) => `${JSON.stringify(k)}:${stableKey(value[k])}`)
151 .join(',')}}`;
152 }
153 return JSON.stringify(value) ?? 'null';
154}
155
156function deepEqual(a: unknown, b: unknown): boolean {
157 return stableKey(a) === stableKey(b);

Callers 1

deepEqualFunction · 0.85

Calls 2

keysMethod · 0.80
isRecordFunction · 0.70

Tested by

no test coverage detected