From ee066c4436702851cb8c2f144fed3293b532fa2c Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 31 Jul 2022 12:39:34 +0300 Subject: [PATCH] fix filesizeformat const/let stuff --- src/services/file_size_format/file_size_format.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/services/file_size_format/file_size_format.js b/src/services/file_size_format/file_size_format.js index d481dfb0f0..17deb09b2b 100644 --- a/src/services/file_size_format/file_size_format.js +++ b/src/services/file_size_format/file_size_format.js @@ -1,14 +1,13 @@ -const fileSizeFormat = (num) => { - let exponent - let unit +const fileSizeFormat = (numArg) => { const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB'] + let num = numArg if (num < 1) { return num + ' ' + units[0] } - exponent = Math.min(Math.floor(Math.log(num) / Math.log(1024)), units.length - 1) + const exponent = Math.min(Math.floor(Math.log(num) / Math.log(1024)), units.length - 1) num = (num / Math.pow(1024, exponent)).toFixed(2) * 1 - unit = units[exponent] + const unit = units[exponent] return { num, unit } } const fileSizeFormatService = {