Files
callstack__agent-device/scripts/size-report-format.mjs
Michał Pierzchała 30de1597d3 ci: attribute native package size and trim Apple runner (#1934)
* ci: attribute npm package size by shipped component

* refactor: modularize size reporting and trim Apple runner

* ci: preserve size reporter modules across base checkout
2026-08-21 13:46:53 +02:00

21 lines
659 B
JavaScript

export function formatMaybeBytes(value) {
return typeof value === 'number' ? formatBytes(value) : '-';
}
export function formatDiff(base, current) {
return typeof base === 'number' ? formatSignedBytes(current - base) : '-';
}
export function formatBytes(value) {
const absoluteValue = Math.abs(value);
if (absoluteValue < 1000) return `${value} B`;
if (absoluteValue < 1000 * 1000) return `${(value / 1000).toFixed(1)} kB`;
return `${(value / (1000 * 1000)).toFixed(2)} MB`;
}
export function formatSignedBytes(value) {
if (value === 0) return '0 B';
const sign = value > 0 ? '+' : '-';
return `${sign}${formatBytes(Math.abs(value))}`;
}