humanReadableFileSize
Commons
stable
Formats a raw byte count into a human-readable string using either SI (base-1000: k, M, G) or IEC (base-1024: Ki, Mi, Gi) prefixes.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- bytesrequirednumber
- The raw size in bytes.
- base1000 | 10241000
- The numeric base. 1000 uses SI prefixes (kB, MB, GB); 1024 uses IEC binary prefixes (KiB, MiB, GiB).
API
Return value
The value returned by this util.
- A formatted string such as "1.4 kB" or "3.7 MiB". Values below the base threshold are returned as "N B".
Usage
Examples
Ready-to-paste usage snippets.
SI vs IEC formatting