Wrap code for page.evaluate(), using async IIFE with block or expression body as needed.
(code: string)
| 39 | |
| 40 | /** Wrap code for page.evaluate(), using async IIFE with block or expression body as needed. */ |
| 41 | function wrapForEvaluate(code: string): string { |
| 42 | if (!hasAwait(code)) return code; |
| 43 | const trimmed = code.trim(); |
| 44 | return needsBlockWrapper(trimmed) |
| 45 | ? `(async()=>{\n${code}\n})()` |
| 46 | : `(async()=>(${trimmed}))()`; |
| 47 | } |
| 48 | |
| 49 | /** Flags split out of `js`/`eval` args by parseOutArgs. */ |
| 50 | export interface OutArgs { |
no test coverage detected