1.0.1 • Published 7 years ago
format-bytes v1.0.1
format-bytes.js
Formats a byte count for human reading.
- Home: https://github.com/twhb/format-bytes.js
- npm: format-bytes
Examples
formatBytes(8) === '8 bytes';
formatBytes(3171) === '3.17 KB';
formatBytes(Number.MAX_SAFE_INTEGER) === '9.01 PB';
formatBytes(Number.MAX_VALUE) === '1.80 × 10^308 bytes';
API
formatBytes(bytes)
Returns a string representing bytes
for human reading. Uses the units bytes
, KB
, MB
… YB
, with larger numbers in scientific notation. Rounding may occur.
bytes: An integer >= 0, the byte count to format.