(raw: unknown)
| 87 | } |
| 88 | |
| 89 | function serializeValue(raw: unknown): string { |
| 90 | if (typeof raw === 'string') return redactString(raw); |
| 91 | if (raw === undefined) return 'undefined'; |
| 92 | if (raw === null) return 'null'; |
| 93 | if ( |
| 94 | typeof raw === 'number' || |
| 95 | typeof raw === 'boolean' || |
| 96 | typeof raw === 'bigint' || |
| 97 | typeof raw === 'symbol' |
| 98 | ) { |
| 99 | return String(raw); |
| 100 | } |
| 101 | try { |
| 102 | const json = JSON.stringify(raw); |
| 103 | if (json !== undefined) return json; |
| 104 | } catch { |
| 105 | // fall through to a stable non-contentful fallback |
| 106 | } |
| 107 | if (typeof raw === 'function') return raw.name === '' ? '[Function]' : `[Function: ${raw.name}]`; |
| 108 | return Object.prototype.toString.call(raw); |
| 109 | } |
| 110 | |
| 111 | function redactString(value: string): string { |
| 112 | let out = value; |
no test coverage detected