(input: unknown, options?: {
readonly space?: number | string | undefined
})
| 295 | export function formatJson(input: unknown, options?: { |
| 296 | readonly space?: number | string | undefined |
| 297 | }): string { |
| 298 | const ancestors: Array<object> = [] |
| 299 | return JSON.stringify( |
| 300 | input, |
| 301 | function(this: unknown, _key: string, value: unknown) { |
| 302 | const redacted = redact(value) |
| 303 | if (typeof redacted !== "object" || redacted === null) { |
| 304 | return redacted |
| 305 | } |
| 306 | while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this) { |
| 307 | ancestors.pop() |
| 308 | } |
| 309 | if (ancestors.includes(redacted)) { |
| 310 | return undefined // circular reference |
| 311 | } |
| 312 | ancestors.push(redacted) |
| 313 | return redacted |
| 314 | }, |
| 315 | options?.space |
| 316 | ) ?? "null" |
| 317 | } |
no test coverage detected
searching dependent graphs…