export class FileSizeUtil { static transform ( bytes = 0 , precision = 2 ) { if ( bytes === 0 ) { return '0 Bytes' ; } const k = 1000 , sizes = [ 'Bytes' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' ] , i = Math . floor ( Math . log ( bytes ) / Math . log ( k ) ) ; return parseFloat ( ( bytes / Math . pow ( k , i ) ) . toFixed ( precision ) ) + ' ' + sizes [ i ] ; } }