3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 14:45:44 +01:00

Answer stability round 1: 0 🔴, 4 🟡 (0 misread); kill the minify and boundary mutants, derive the comparison's esbuild pin, measure the companion sizes

This commit is contained in:
2026-11-15 13:45:04 +01:00
committed by Lillem4n
parent 6b7a8e691b
commit 750331e825
5 changed files with 49 additions and 18 deletions
+6 -7
View File
@@ -3,18 +3,16 @@ import { execFileSync } from "node:child_process";
import { gzipSync } from "node:zlib";
const bytesPerKilobyte = 1000;
// A published figure stays true while it is within this share of the measure.
const tolerance = 0.1;
// What a consumer's bundler ships for the package: its code and its dependencies, minified, gzipped.
export const minifiedGzippedBytes = async (resolveDir, specifier) => {
// What a consumer's bundler ships for the whole of the packages: their code and dependencies, minified, gzipped.
export const minifiedGzippedBytes = async (resolveDir, specifiers) => {
const { outputFiles } = await build({
bundle: true,
format: "esm",
logLevel: "silent",
minify: true,
platform: "node",
stdin: { contents: `export * from ${JSON.stringify(specifier)};`, resolveDir },
stdin: { contents: specifiers.map((specifier) => `export * from ${JSON.stringify(specifier)};`).join("\n"), resolveDir },
write: false,
});
return gzipSync(outputFiles[0].contents, { level: 9 }).length;
@@ -33,10 +31,11 @@ const published = [
];
const tableCell = new RegExp(`^\\| \`@larvit/adf-codec\` \\|.*\\| ${number} kB \\|$`, "m");
const offBy = (claimed, bytes) => Math.abs(Number(claimed) - bytes / bytesPerKilobyte) > tolerance * bytes / bytesPerKilobyte;
// Whole bytes keep the bound exact: 0.1 has no binary spelling.
const offBy = (claimed, bytes) => Math.abs(Math.round(Number(claimed) * bytesPerKilobyte) - bytes) * 10 > bytes;
const kilobytes = (bytes) => (bytes / bytesPerKilobyte).toFixed(1);
// The README's size claims that no longer match the measure, each as a sentence.
// The README's size claims that are missing or more than a tenth off the measure, each as a sentence.
export const drift = (readme, measured) => [
...published.flatMap(([key, label, pattern]) => {
const found = pattern.exec(readme);