synapse-react-client
Version:
[](https://travis-ci.com/Sage-Bionetworks/Synapse-React-Client) [](https://badge.fury.io/js/synaps
26 lines • 740 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.calculateFriendlyFileSize = void 0;
var sufixes = [
'Bytes',
'KB',
'MB',
'GB',
'TB',
'PB',
'EB',
'ZB',
'YB',
];
function calculateFriendlyFileSize(bytes) {
if (!bytes) {
return '';
}
// https://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable-string
var i = Math.floor(Math.log(bytes) / Math.log(1024));
// tslint:disable-next-line
return ((!bytes && '0 Bytes') ||
(bytes / Math.pow(1024, i)).toFixed(2) + ' ' + sufixes[i]);
}
exports.calculateFriendlyFileSize = calculateFriendlyFileSize;
//# sourceMappingURL=calculateFriendlyFileSize.js.map