(code: string)
| 45 | )(...Object.values(params)) |
| 46 | |
| 47 | export const executeCode = (code: string): ExecutionResult => { |
| 48 | try { |
| 49 | const { |
| 50 | [playgroundTypeVariableName]: parsed, |
| 51 | [playgroundOutVariableName]: traversed |
| 52 | } = evaluate(isolate(code), [ |
| 53 | playgroundTypeVariableName, |
| 54 | playgroundOutVariableName |
| 55 | ]) |
| 56 | |
| 57 | return { |
| 58 | parsed: parsed as ParseResult, |
| 59 | traversed: traversed as TraverseResult, |
| 60 | js: code |
| 61 | } |
| 62 | } catch (e) { |
| 63 | return { |
| 64 | parsed: |
| 65 | e instanceof Error ? e : new ReferenceError(playgroundTypeVariableName), |
| 66 | traversed: unset |
| 67 | } |
| 68 | } |
| 69 | } |
no test coverage detected