(value: unknown)
| 56 | * matching the stable-serialization callers this serves. |
| 57 | */ |
| 58 | export function sortObjectKeysDeep(value: unknown): unknown { |
| 59 | if (Array.isArray(value)) { |
| 60 | return value.map(sortObjectKeysDeep) |
| 61 | } |
| 62 | if (value !== null && typeof value === 'object') { |
| 63 | const obj = value as Record<string, unknown> |
| 64 | return Object.keys(obj) |
| 65 | .sort() |
| 66 | .reduce((result: Record<string, unknown>, key: string) => { |
| 67 | result[key] = sortObjectKeysDeep(obj[key]) |
| 68 | return result |
| 69 | }, {}) |
| 70 | } |
| 71 | return value |
| 72 | } |
no outgoing calls
no test coverage detected