From 6e997ab62eb6daf78d4d4f75b63dae9b6797b3a1 Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle <patrizio@bekerle.com> Date: Mon, 30 Mar 2020 09:31:42 +0200 Subject: [PATCH] Switch to common units in humanFileSize --- packages/common/i18next.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/common/i18next.js b/packages/common/i18next.js index b6908149..d2b47153 100644 --- a/packages/common/i18next.js +++ b/packages/common/i18next.js @@ -28,14 +28,12 @@ export function numberFormat(i18n, number, options) { return new Intl.NumberFormat(i18n.languages, options).format(number); } -export function humanFileSize(bytes, si) { +export function humanFileSize(bytes, si = false) { const thresh = si ? 1000 : 1024; if(Math.abs(bytes) < thresh) { return bytes + ' B'; } - const units = si - ? ['kB','MB','GB','TB','PB','EB','ZB','YB'] - : ['KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB']; + const units = ['kB','MB','GB','TB','PB','EB','ZB','YB']; let u = -1; do { bytes /= thresh; -- GitLab