@selfcommunity/react-ui
Version:
React UI Components to integrate a Community created with SelfCommunity Platform.
14 lines (13 loc) • 475 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.bytesToSize = void 0;
function bytesToSize(bytes) {
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes === 0)
return 'n/a';
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)).toString());
if (i === 0)
return `${bytes} ${sizes[i]}`;
return `${(bytes / Math.pow(1024, i)).toFixed(1)} ${sizes[i]}`;
}
exports.bytesToSize = bytesToSize;
;