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