From dc6f72adf41914be1aefd43a498daf54dbc6b5ce Mon Sep 17 00:00:00 2001
From: Kai Reinhard <K.Reinhard@micromata.de>
Date: Sat, 15 Dec 2018 08:15:13 +0000
Subject: [PATCH] humanFilesize...
---
borgbutler-webapp/src/utilities/global.js | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/borgbutler-webapp/src/utilities/global.js b/borgbutler-webapp/src/utilities/global.js
index 4faa037..05ac0d3 100644
--- a/borgbutler-webapp/src/utilities/global.js
+++ b/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);
--
Gitblit v1.10.0