(codeString: string)
| 1 | function containsGeneratorFunction(codeString: string): boolean { |
| 2 | // Regular expression to detect generator function declaration (function* name() {}) |
| 3 | const generatorFunctionPattern = /\bfunction\s*\*/; |
| 4 | |
| 5 | // Regular expression to detect arrow function generators (async function* () => {}) |
| 6 | const arrowGeneratorPattern = /\*\s*=>/; |
| 7 | |
| 8 | // Test the string for both patterns |
| 9 | return ( |
| 10 | generatorFunctionPattern.test(codeString) || arrowGeneratorPattern.test(codeString) |
| 11 | ); |
| 12 | } |
| 13 | |
| 14 | const createSandboxedFunction = function ( |
| 15 | args: Record<string, string>, |
no outgoing calls
no test coverage detected