(x: unknown)
| 31 | * @since 2.0.0 |
| 32 | */ |
| 33 | export const toJSON = (x: unknown): unknown => { |
| 34 | try { |
| 35 | if ( |
| 36 | Predicate.hasProperty(x, "toJSON") && Predicate.isFunction(x["toJSON"]) && |
| 37 | x["toJSON"].length === 0 |
| 38 | ) { |
| 39 | return x.toJSON() |
| 40 | } else if (Array.isArray(x)) { |
| 41 | return x.map(toJSON) |
| 42 | } |
| 43 | } catch { |
| 44 | return {} |
| 45 | } |
| 46 | return redact(x) |
| 47 | } |
| 48 | |
| 49 | const CIRCULAR = "[Circular]" |
| 50 |