From 7c86b866bff9b604ee84194872ee04e3470f1281 Mon Sep 17 00:00:00 2001
From: syuilo <syuilotan@yahoo.co.jp>
Date: Sun, 11 Jun 2017 06:08:44 +0900
Subject: [PATCH] [Client] Improve bytes-to-size function

Add the digits argument
---
 src/web/app/common/scripts/bytes-to-size.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/web/app/common/scripts/bytes-to-size.js b/src/web/app/common/scripts/bytes-to-size.js
index e143387141..af0268dbd0 100644
--- a/src/web/app/common/scripts/bytes-to-size.js
+++ b/src/web/app/common/scripts/bytes-to-size.js
@@ -1,6 +1,6 @@
-export default bytes => {
+export default (bytes, digits = 0) => {
 	var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
 	if (bytes == 0) return '0Byte';
 	var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
-	return Math.round(bytes / Math.pow(1024, i), 2) + sizes[i];
+	return (bytes / Math.pow(1024, i)).toFixed(digits).replace(/\.0+$/, '') + sizes[i];
 };