pols-utils - v5.3.11
    Preparing search index...

    Function sizeRepresentation

    • Converts a numeric value to a human-readable string representing a size in bytes. The value is divided by 1024 iteratively until it fits into a suitable unit (K, M, G, etc.).

      Parameters

      • size: number

        The numeric value in bytes to format.

      • config: { decimalSeparator?: string; thousandSeparator?: string } = {}

        Configuration object.

        • OptionaldecimalSeparator?: string

          Default '.'. Character to use as the decimal separator.

        • OptionalthousandSeparator?: string

          Default ','. Character to use as the thousand separator.

      Returns string

      A string representation of the size with the appropriate unit.

      console.log(PUtilsNumber.sizeRepresentation(2300)) // "2.25 K"
      console.log(PUtilsNumber.sizeRepresentation(2300456)) // "2.19 M"
      console.log(PUtilsNumber.sizeRepresentation(1048576)) // "1.00 M"
      console.log(PUtilsNumber.sizeRepresentation(1099511627776)) // "1.00 T"