@limetech/lime-elements
Version:
21 lines • 746 B
TypeScript
/**
* Format a file size in bytes into a human readable string.
*
* Uses base 1024 units (binary prefixes without the "i" designation)
* and applies adaptive precision: one decimal for values < 10 of the
* chosen unit, otherwise no decimals.
*
* Examples:
* - 0 => "0 B"
* - 512 => "512 B"
* - 1536 => "1.5 KB"
* - 1048576 => "1 MB"
* - 5368709120 => "5 GB"
* - formatBytes(5347737600, 2) => "4.98 GB" (value < 10 so two decimals)
*
* @param bytes - the size in bytes
* @param decimals - max number of decimals for small unit values (default: 1)
* @returns formatted size string
*/
export declare function formatBytes(bytes: number | undefined | null, decimals?: number): string;
//# sourceMappingURL=format-bytes.d.ts.map