• Function to convert bytes to an abbreviated format

    Parameters

    • bytes: number

      Number of bytes

    • numOfFractionalDigits: number = 2

      Number of digits after the decimal place

    Returns string

    String representing the bytes in abbreviated form (KB, MB, GB, etc.)

    convertBytesToString(1024); // 1 KB
    convertBytesToString(1027); // 1.00 KB
    convertBytesToString(1500000); // 1.43 MB