@welshare/sdk
    Preparing search index...

    Function formatFileSize

    • Format a byte count to a human-readable file size string.

      Uses binary units (1 KB = 1024 bytes) which is standard for file sizes.

      Parameters

      • bytes: number

        Number of bytes

      • decimals: number = 2

        Number of decimal places (default: 2)

      Returns string

      Formatted file size string (e.g., "1.5 MB")

      formatFileSize(0); // "0 Bytes"
      formatFileSize(1024); // "1 KB"
      formatFileSize(1536); // "1.5 KB"
      formatFileSize(1048576); // "1 MB"
      formatFileSize(1073741824); // "1 GB"
      formatFileSize(1536, 0); // "2 KB"