* Safely stringify an object, handling circular references. * Replaces circular references with '[Circular]' placeholder.
(obj: unknown)
| 47 | * Replaces circular references with '[Circular]' placeholder. |
| 48 | */ |
| 49 | function safeStringify(obj: unknown): string { |
| 50 | const seen = new WeakSet() |
| 51 | return JSON.stringify(obj, (_key, value) => { |
| 52 | if (typeof value === 'object' && value !== null) { |
| 53 | if (seen.has(value)) { |
| 54 | return '[Circular]' |
| 55 | } |
| 56 | seen.add(value) |
| 57 | } |
| 58 | return value |
| 59 | }) |
| 60 | } |
| 61 | |
| 62 | function isEmptyObject(value: any): boolean { |
| 63 | return ( |
no outgoing calls
no test coverage detected