@eroyeroy/utils - v0.1.0
    Preparing search index...

    Function formatBytes

    • Formats a byte count as a human-readable string with an appropriate unit.

      Parameters

      • bytes: number

        Number of bytes.

      • precision: number = 2

        Number of decimal places. Defaults to 2.

      Returns string

      formatBytes(0)          // => "0 B"
      formatBytes(1024) // => "1.00 KB"
      formatBytes(1048576, 1) // => "1.0 MB"