/** * Byte-size formatting. * * Two conventions exist in the wild and they disagree by ~7% at MB and ~10% at GB: * * - **Binary** (`base: 1024`) — what most developer tooling does, including every * shipped extension in this fleet except one. Note it is technically mislabelled: * dividing by 1024 and calling the result `KB` is what `KiB` means. * - **Decimal** (`base: 1000`) — what macOS Finder reports, and has since 10.6. * Match this when the number sits next to something the user can also see in Finder. * * Neither is "correct" in the abstract, so `base` is an explicit choice with a * developer-conventional default rather than a value hardcoded out of sight. */ export interface FormatBytesOptions { /** Divisor between units. Default 1024 (binary). Pass 1000 to match macOS Finder. */ base?: 1000 | 1024; /** * Fraction digits for KB and above. Default 1. Bytes are always whole — a * fractional byte is not a thing, and `"512.0 B"` reads as a rounding artefact. */ precision?: number; /** * Strip trailing zeros, so 1 MB renders `"1 MB"` rather than `"1.0 MB"`. * Default false. */ trimZeros?: boolean; } /** * Format a byte count for display. * * @example * formatBytes(0) // "0 B" * formatBytes(512) // "512 B" * formatBytes(1536) // "1.5 KB" * formatBytes(1_500_000, { base: 1000 }) // "1.5 MB" (Finder's answer) * formatBytes(1_048_576) // "1.0 MB" * formatBytes(1_048_576, { trimZeros: true }) // "1 MB" */ export declare function formatBytes(bytes: number, options?: FormatBytesOptions): string; /** * Format a transfer rate. Takes the same options so a progress line's rate and its * total cannot silently use different bases. */ export declare function formatSpeed(bytesPerSecond: number, options?: FormatBytesOptions): string; //# sourceMappingURL=bytes.d.ts.map