(code: string)
| 7 | } |
| 8 | |
| 9 | function isJSON(code: string): boolean { |
| 10 | const input = code.trim(); |
| 11 | if (!input.startsWith('{') || !input.endsWith('}')) { |
| 12 | return false; |
| 13 | } |
| 14 | try { |
| 15 | const output = JSON.parse(input); |
| 16 | return typeof output === 'object'; |
| 17 | } catch (exception) { |
| 18 | return false; |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | export function formatCode(code: string): string { |
| 23 | if (isJSON(code)) { |
no outgoing calls
no test coverage detected