mazey
    Preparing search index...

    Function formatByteSize

    • Format a non-negative byte count using B, KB, MB, GB, or TB.

      Scaling defaults to 1024 with one fractional digit. Byte values omit insignificant trailing zeroes, while scaled values retain the requested number of fractional digits. Values beyond terabytes remain expressed in TB.

      Usage:

      import { formatByteSize } from "mazey";

      formatByteSize(0); // "0 B"
      formatByteSize(1536); // "1.5 KB"
      formatByteSize(1500000, { base: 1000, fractionDigits: 2 }); // "1.50 MB"

      Parameters

      Returns string

      A formatted byte-size string, or invalidValue for invalid input.