/** * @copyright Sister Software. * @license AGPL-3.0 * @author Teffen Ellis, et al. */ /** * A kibibyte. Named so a `< 1024` guard reads as a threshold rather than a magic number — several fetchers use it to * reject a response too small to be the archive they asked for. */ export declare const BYTES_PER_KIB = 1024; export interface ByteFormatterOptions { /** * Prefix an explicit `+` on a positive value. For a DELTA, where the sign is the information. A negative always * carries its own sign. */ signed?: boolean; /** * Override the formatter's locale for this call. */ locales?: Intl.LocalesArgument; } /** * Byte counts as a human reads them, in whichever of the two bases the number was actually measured in. * * Both bases, spelled correctly. A formatter that divides by 1024 and prints `KB` is off by 2.4% at KB and 10% by TB, * and the label is the only thing telling a reader which it did — so the choice is named at the call site: * * - {@linkcode ByteFormatter.formatIEC} for anything a MACHINE measured — heap, file size on disk, buffer length. * - {@linkcode ByteFormatter.formatSI} for a size a VENDOR reports. Disk capacity, download sizes and GitHub's own API * are quoted in powers of ten; rendering GitHub's `41.3 GB` as `38.5 GiB` is correct arithmetic and the wrong * answer. * * Rendering goes through `Intl.NumberFormat`, so the unit and the decimal separator follow the locale. Pass an explicit * locale when a caller needs a stable string — a test asserting an exact rendering, not a line printed for a human. */ export declare class ByteFormatter { static SI_UNITS: readonly ["byte", "kilobyte", "megabyte", "gigabyte", "terabyte"]; static IEC_UNITS: readonly ["B", "KiB", "MiB", "GiB", "TiB"]; static shared: ByteFormatter; static formatSI(bytes: number, options?: ByteFormatterOptions): string; static formatIEC(bytes: number, options?: ByteFormatterOptions): string; protected locales?: Intl.LocalesArgument; constructor(locales?: Intl.LocalesArgument); /** * Formats a file size in bytes into a human-readable string with appropriate SI units (B, kB, MB, GB, TB). * * @param bytes The file size in bytes. */ formatSI(bytes: number, options?: ByteFormatterOptions): string; /** * Formats a file size in bytes into a human-readable string with appropriate IEC units (B, KiB, MiB, GiB, TiB). * * @param bytes The file size in bytes. */ formatIEC(bytes: number, options?: ByteFormatterOptions): string; } //# sourceMappingURL=formatters.d.ts.map