(inspectOutput: string)
| 1020 | }); |
| 1021 | |
| 1022 | function convertInspectToJSON(inspectOutput: string) { |
| 1023 | const jsonLikeString = inspectOutput |
| 1024 | .replace(/'([^']+)'/g, '"$1"') // single-quoted strings |
| 1025 | .replace(/([a-zA-Z0-9_]+):/g, '"$1":') // unquoted object keys |
| 1026 | .replace(/\bundefined\b/g, 'null') |
| 1027 | .replace(/\[Function(: [^\]]+)?\]/g, '"[Function]"') |
| 1028 | .replace(/\[Circular\]/g, '"[Circular]"'); |
| 1029 | |
| 1030 | try { |
| 1031 | return JSON.parse(jsonLikeString); |
| 1032 | } catch (error) { |
| 1033 | console.error('Error parsing the modified inspect output:', error); |
| 1034 | throw error; |
| 1035 | } |
| 1036 | } |
no test coverage detected