src/utils/StringUtils.js
function prettyPrintBytes(bytes, precision) {
        var kilobyte = 1024,
            megabyte = kilobyte * 1024,
            gigabyte = megabyte * 1024,
            terabyte = gigabyte * 1024,
            returnVal = bytes;

        if ((bytes >= 0) && (bytes < kilobyte)) {
            returnVal = bytes + " B";
        } else if (bytes < megabyte) {
            returnVal = (bytes / kilobyte).toFixed(precision) + " KB";
        } else if (bytes < gigabyte) {
            returnVal = (bytes / megabyte).toFixed(precision) + " MB";
        } else if (bytes < terabyte) {
            returnVal = (bytes / gigabyte).toFixed(precision) + " GB";
        } else if (bytes >= terabyte) {
            return (bytes / terabyte).toFixed(precision) + " TB";
        }

        return returnVal;
    }
function prettyPrintBytes(bytes, precision) {
        var kilobyte = 1024,
            megabyte = kilobyte * 1024,
            gigabyte = megabyte * 1024,
            terabyte = gigabyte * 1024,
            returnVal = bytes;

        if ((bytes >= 0) && (bytes < kilobyte)) {
            returnVal = bytes + " B";
        } else if (bytes < megabyte) {
            returnVal = (bytes / kilobyte).toFixed(precision) + " KB";
        } else if (bytes < gigabyte) {
            returnVal = (bytes / megabyte).toFixed(precision) + " MB";
        } else if (bytes < terabyte) {
            returnVal = (bytes / gigabyte).toFixed(precision) + " GB";
        } else if (bytes >= terabyte) {
            return (bytes / terabyte).toFixed(precision) + " TB";
        }

        return returnVal;
    }
function prettyPrintBytes ( bytes , precision ) { var kilobyte = 1024 , megabyte = kilobyte * 1024 , gigabyte = megabyte * 1024 , terabyte = gigabyte * 1024 , returnVal = bytes ; if ( ( bytes >= 0 ) && ( bytes < kilobyte ) ) { returnVal = bytes + " B" ; } else if ( bytes < megabyte ) { returnVal = ( bytes / kilobyte ) . toFixed ( precision ) + " KB" ; } else if ( bytes < gigabyte ) { returnVal = ( bytes / megabyte ) . toFixed ( precision ) + " MB" ; } else if ( bytes < terabyte ) { returnVal = ( bytes / gigabyte ) . toFixed ( precision ) + " GB" ; } else if ( bytes >= terabyte ) { return ( bytes / terabyte ) . toFixed ( precision ) + " TB" ; } return returnVal ; }
Converts number of bytes into human readable format.
If param bytes is negative it returns the number without any changes.

@param {number} bytes     Number of bytes to convert
@param {number} precision Number of digits after the decimal separator
@return {string}
Converts number of bytes into human readable format . If param bytes is negative it returns the number without any changes .