formatSize
Format a byte count into a human-readable string with the appropriate unit.
Each unit is 1024 of the previous (binary prefix). The result is formatted with one decimal place.
Available since v2.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
bytes | number | A non-negative integer representing a byte count. |
Returns
Section titled “Returns”string — A human-readable string such as '0.0B', '1.5KB', '3.2MB'.
Examples
Section titled “Examples”Format bytes to human-readable size
Section titled “Format bytes to human-readable size”Converts a raw byte count to a human-readable string using binary prefixes.
