* Recursively sort all keys in an object to match Python's json.dumps(sort_keys=True)
(obj: unknown)
| 110 | * Recursively sort all keys in an object to match Python's json.dumps(sort_keys=True) |
| 111 | */ |
| 112 | function sortKeysDeep(obj: unknown): unknown { |
| 113 | if (Array.isArray(obj)) { |
| 114 | return obj.map(sortKeysDeep) |
| 115 | } |
| 116 | if (obj !== null && typeof obj === 'object') { |
| 117 | const sorted: Record<string, unknown> = {} |
| 118 | for (const key of Object.keys(obj).sort()) { |
| 119 | sorted[key] = sortKeysDeep((obj as Record<string, unknown>)[key]) |
| 120 | } |
| 121 | return sorted |
| 122 | } |
| 123 | return obj |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Compute checksum from settings content for HTTP caching |
no test coverage detected