function bytesToHumanSize(bytes) {
  if (!bytes || bytes === 0) {
    return '0 Bytes';
  }

  var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
  var bucket = Math.min(Math.floor(Math.log2(bytes) / 10) | 0, sizes.length - 1);
  var count = bytes / Math.pow(1024, bucket);
  var round = bucket > 0 ? (count < 3 ? 2 : count < 30 ? 1 : 0) : 0;
  return count.toFixed(round) + ' ' + sizes[bucket];
}
// Convert a number of bytes to human-readable format.
Convert a number of bytes to human-readable format.
Convert a number of bytes to human - readable format .
function bytesToHumanSize(bytes) {
  if (!bytes || bytes === 0) {
    return '0 Bytes';
  }
  var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
  var bucket = Math.min(Math.floor(Math.log2(bytes) / 10) | 0, sizes.length - 1);
  var count = bytes / Math.pow(1024, bucket);
  var round = bucket > 0 ? (count < 3 ? 2 : count < 30 ? 1 : 0) : 0;
  return count.toFixed(round) + ' ' + sizes[bucket];
}
function bytesToHumanSize ( bytes ) { if ( ! bytes || bytes === 0 ) { return '0 Bytes' ; } var sizes = [ 'Bytes' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' ] ; var bucket = Math . min ( Math . floor ( Math . log2 ( bytes ) / 10 ) | 0 , sizes . length - 1 ) ; var count = bytes / Math . pow ( 1024 , bucket ) ; var round = bucket > 0 ? ( count < 3 ? 2 : count < 30 ? 1 : 0 ) : 0 ; return count . toFixed ( round ) + ' ' + sizes [ bucket ] ; }
Convert a number of bytes to human-readable format.
Convert a number of bytes to human - readable format .