(source: string)
| 120 | }; |
| 121 | |
| 122 | const renderHeuristicBody = (source: string): string => { |
| 123 | const withoutDefaultExport = source.replace(/^export\s+default\s+/, "").trim(); |
| 124 | |
| 125 | if ( |
| 126 | (withoutDefaultExport.startsWith("async") || withoutDefaultExport.startsWith("(")) && |
| 127 | withoutDefaultExport.includes("=>") |
| 128 | ) { |
| 129 | return wrapCallableBody(withoutDefaultExport); |
| 130 | } |
| 131 | |
| 132 | if (FUNCTION_DECLARATION.test(withoutDefaultExport)) { |
| 133 | const name = withoutDefaultExport.match(FUNCTION_DECLARATION)?.[1]; |
| 134 | return name |
| 135 | ? wrapNamedFunctionBody(withoutDefaultExport, name) |
| 136 | : wrapAnonymousFunctionBody(withoutDefaultExport); |
| 137 | } |
| 138 | |
| 139 | return withoutDefaultExport; |
| 140 | }; |
| 141 | |
| 142 | export const recoverExecutionBody = (code: string): string => { |
| 143 | const source = extractCandidateSource(code); |
no test coverage detected