MCPcopy Create free account
hub / github.com/codeaashu/claude-code / sortKeysDeep

Function sortKeysDeep

src/services/policyLimits/index.ts:133–147  ·  view source on GitHub ↗

* Recursively sort all keys in an object for consistent hashing

(obj: unknown)

Source from the content-addressed store, hash-verified

131 * Recursively sort all keys in an object for consistent hashing
132 */
133function sortKeysDeep(obj: unknown): unknown {
134 if (Array.isArray(obj)) {
135 return obj.map(sortKeysDeep)
136 }
137 if (obj !== null && typeof obj === 'object') {
138 const sorted: Record<string, unknown> = {}
139 for (const [key, value] of Object.entries(obj).sort(([a], [b]) =>
140 a.localeCompare(b),
141 )) {
142 sorted[key] = sortKeysDeep(value)
143 }
144 return sorted
145 }
146 return obj
147}
148
149/**
150 * Compute a checksum from restrictions content for HTTP caching

Callers 1

computeChecksumFunction · 0.70

Calls 1

entriesMethod · 0.80

Tested by

no test coverage detected