(raw)
| 62 | } |
| 63 | |
| 64 | function parseMaybeDataJs(raw) { |
| 65 | const trimmed = raw.trim() |
| 66 | |
| 67 | if (trimmed.startsWith('window.BENCHMARK_DATA')) { |
| 68 | const sandbox = { window: {} } |
| 69 | vm.runInNewContext(trimmed, sandbox, { timeout: 1000 }) |
| 70 | return sandbox.window.BENCHMARK_DATA |
| 71 | } |
| 72 | |
| 73 | return JSON.parse(trimmed) |
| 74 | } |
| 75 | |
| 76 | function readJsonMaybeData(filePath) { |
| 77 | return parseMaybeDataJs(fs.readFileSync(filePath, 'utf8')) |
no test coverage detected