format-bytes

1.0.1 • Public • Published

format-bytes.js

Formats a byte count for human reading.

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, MBYB, with larger numbers in scientific notation. Rounding may occur.

bytes: An integer >= 0, the byte count to format.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i format-bytes

      Weekly Downloads

      67

      Version

      1.0.1

      License

      none

      Last publish

      Collaborators

      • twhb