From 545656007b1ec0ea785b4c5e0dd53aa57da09161 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 28 Mar 2026 14:26:19 +0100 Subject: [PATCH] Use a standard import for the `ttest` package in `test/stats/statcmp.js` Since this code is quite old parts of it can also be simplified a little bit by using modern string methods, which removes the need for the `pad` helper function. --- test/stats/statcmp.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/test/stats/statcmp.js b/test/stats/statcmp.js index f3d4f80e7..5cf20b05b 100644 --- a/test/stats/statcmp.js +++ b/test/stats/statcmp.js @@ -1,11 +1,6 @@ -/* eslint-disable import/no-commonjs */ - -import { createRequire } from "module"; import fs from "fs"; import { parseArgs } from "node:util"; - -const require = createRequire(import.meta.url); -const ttest = require("ttest"); +import ttest from "ttest"; const VALID_GROUP_BYS = ["browser", "pdf", "page", "round", "stat"]; @@ -72,12 +67,6 @@ function flatten(stats) { return rows; } -function pad(s, length, dir /* default: 'right' */) { - s = "" + s; - const spaces = new Array(Math.max(0, length - s.length + 1)).join(" "); - return dir === "left" ? spaces + s : s + spaces; -} - function mean(array) { return array.reduce((a, b) => a + b, 0) / array.length; } @@ -158,7 +147,7 @@ function stat(baseline, current) { } // add horizontal line - const hline = width.map(w => new Array(w + 1).join("-")); + const hline = width.map(w => "-".repeat(w)); rows.splice(1, 0, hline); // print output @@ -166,7 +155,8 @@ function stat(baseline, current) { const groupCount = options.groupBy.length; for (const row of rows) { for (let i = 0; i < row.length; i++) { - row[i] = pad(row[i], width[i], i < groupCount ? "right" : "left"); + row[i] = + i < groupCount ? row[i].padEnd(width[i]) : row[i].padStart(width[i]); } console.log(row.join(" | ")); }