Skip to content

Commit e381ad6

Browse files
committed
add missing isInBrowser check and use switch for result format selection
1 parent 251eb95 commit e381ad6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

JetStreamDriver.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,8 @@ class Driver {
467467
}
468468

469469
async initialize() {
470-
window.addEventListener("error", (e) => this.pushError("driver startup", e.error));
470+
if (isInBrowser)
471+
window.addEventListener("error", (e) => this.pushError("driver startup", e.error));
471472
await this.prefetchResourcesForBrowser();
472473
await this.fetchResources();
473474
this.prepareToRun();
@@ -529,11 +530,14 @@ class Driver {
529530
}
530531

531532
resultsObject(format = "run-benchmark") {
532-
if (format == "run-benchmark")
533-
return this.runBenchmarkResultsObject();
534-
if (format != "simple")
535-
throw Error(`Unknown result format '${format}'`);
536-
return this.simpleResultsObject();
533+
switch(format) {
534+
case "run-benchmark":
535+
return this.runBenchmarkResultsObject();
536+
case "simple":
537+
return this.simpleResultsObject();
538+
default:
539+
throw Error(`Unknown result format '${format}'`);
540+
}
537541
}
538542

539543
runBenchmarkResultsObject()

0 commit comments

Comments
 (0)