Skip to content

Commit 8941695

Browse files
Merge pull request #20998 from Snuffleupagus/statcmp-import
Use a standard import for the `ttest` package in `test/stats/statcmp.js`
2 parents cdae7a9 + 5456560 commit 8941695

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

test/stats/statcmp.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
/* eslint-disable import/no-commonjs */
2-
3-
import { createRequire } from "module";
41
import fs from "fs";
52
import { parseArgs } from "node:util";
6-
7-
const require = createRequire(import.meta.url);
8-
const ttest = require("ttest");
3+
import ttest from "ttest";
94

105
const VALID_GROUP_BYS = ["browser", "pdf", "page", "round", "stat"];
116

@@ -72,12 +67,6 @@ function flatten(stats) {
7267
return rows;
7368
}
7469

75-
function pad(s, length, dir /* default: 'right' */) {
76-
s = "" + s;
77-
const spaces = new Array(Math.max(0, length - s.length + 1)).join(" ");
78-
return dir === "left" ? spaces + s : s + spaces;
79-
}
80-
8170
function mean(array) {
8271
return array.reduce((a, b) => a + b, 0) / array.length;
8372
}
@@ -158,15 +147,16 @@ function stat(baseline, current) {
158147
}
159148

160149
// add horizontal line
161-
const hline = width.map(w => new Array(w + 1).join("-"));
150+
const hline = width.map(w => "-".repeat(w));
162151
rows.splice(1, 0, hline);
163152

164153
// print output
165154
console.log("-- Grouped By " + options.groupBy.join(", ") + " --");
166155
const groupCount = options.groupBy.length;
167156
for (const row of rows) {
168157
for (let i = 0; i < row.length; i++) {
169-
row[i] = pad(row[i], width[i], i < groupCount ? "right" : "left");
158+
row[i] =
159+
i < groupCount ? row[i].padEnd(width[i]) : row[i].padStart(width[i]);
170160
}
171161
console.log(row.join(" | "));
172162
}

0 commit comments

Comments
 (0)