mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
15.15.2018 dc6f72adf41914be1aefd43a498daf54dbc6b5ce
humanFilesize...
1 files modified
6 ■■■■■ changed files
borgbutler-webapp/src/utilities/global.js 6 ●●●●● patch | view | raw | blame | history
borgbutler-webapp/src/utilities/global.js
@@ -42,8 +42,10 @@
}
export const humanFileSize = (size) => {
    var i = Math.floor( Math.log(size) / Math.log(1024) );
    return (size / Math.pow(1024, i) ).toLocaleString(undefined,{maximumFractionDigits: 2}) + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
    const i = Math.floor( Math.log(size) / Math.log(1024) );
    const amount = size / Math.pow(1024, i);
    const digits = amount < 10 ? 2 : (amount < 100 ? 1 : 0);
    return amount.toLocaleString(undefined,{maximumFractionDigits: digits}) + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
}
export const revisedRandId = () => Math.random().toString(36).replace(/[^a-z]+/g, '').substr(2, 10);