src/Components/Utils.js
/**
     * Format number of bytes as a string with B, KB, MB or GB.
     * The base for all calculations is 1024.
     * @param {number} bytes The number of bytes.
     * @returns {string} The formatted string (e.g. '723.5 KB')
     */
Format number of bytes as a string with B, KB, MB or GB.
The base for all calculations is 1024.
@param {number} bytes The number of bytes.
@returns {string} The formatted string
Format number of bytes as a string with B KB MB or GB . The base for all calculations is 1024 . @param { number } bytes The number of bytes . @returns { string } The formatted string
static formatBytes(bytes) {
        if (Math.abs(bytes) < 1024) {
            return bytes + ' B';
        }
        const units = ['KB','MB','GB'];
        let u = -1;
        do {
            bytes /= 1024;
            ++u;
        } while (Math.abs(bytes) >= 1024 && u < units.length - 1);
        return bytes.toFixed(1) + ' ' + units[u];
    }
static formatBytes ( bytes ) { if ( Math . abs ( bytes ) < 1024 ) { return bytes + ' B' ; } const units = [ 'KB' , 'MB' , 'GB' ] ; let u = - 1 ; do { bytes /= 1024 ; ++ u ; } while ( Math . abs ( bytes ) >= 1024 && u < units . length - 1 ) ; return bytes . toFixed ( 1 ) + ' ' + units [ u ] ; }
Format number of bytes as a string with B, KB, MB or GB.
Format number of bytes as a string with B KB MB or GB .
//const units = ['KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB'];
