cnap-cobre/synapse

View on GitHub
frontend/src/util/FileSize.js

Summary

Maintainability
A
0 mins
Test Coverage
export function humanFileSize(size) {
if (size !== undefined) {
const i = size === 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
return `${(size / (1024 ** i)).toFixed(2) * 1} ${['B', 'kB', 'MB', 'GB', 'TB'][i]}`;
}
return '';
}