(value: unknown)
| 609 | } |
| 610 | |
| 611 | function stable(value: unknown): string { |
| 612 | if (Array.isArray(value)) { |
| 613 | const items = value.map(stable); |
| 614 | const ordered = value.every((item) => item === null || typeof item !== "object") |
| 615 | ? items.sort() |
| 616 | : items; |
| 617 | return `[${ordered.join(",")}]`; |
| 618 | } |
| 619 | if (value !== null && typeof value === "object") { |
| 620 | return `{${Object.entries(value) |
| 621 | .filter(([, item]) => item !== undefined) |
| 622 | .sort(([a], [b]) => a.localeCompare(b)) |
| 623 | .map(([key, item]) => `${JSON.stringify(key)}:${stable(item)}`) |
| 624 | .join(",")}}`; |
| 625 | } |
| 626 | return JSON.stringify(value); |
| 627 | } |
| 628 | |
| 629 | function stripUndefined<T>(value: T): T { |
| 630 | if (Array.isArray(value)) { |
no outgoing calls
no test coverage detected