"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatBytes = formatBytes;
function formatBytes(bytes, fractionDigits = 1) {
    if (!Number.isFinite(bytes) || bytes < 0)
        return 'unknown';
    if (bytes === 0)
        return '0 B';
    const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'];
    let value = bytes;
    let unit = 0;
    while (value >= 1024 && unit < units.length - 1) {
        value /= 1024;
        unit++;
    }
    const formatted = unit === 0 ? value.toString() : value.toFixed(fractionDigits);
    return `${formatted} ${units[unit]}`;
}
