mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-09 00:59:02 +03:00
feat: show precise file size with decimal (#210)
This commit is contained in:
@@ -778,7 +778,11 @@ function formatSize(size) {
|
|||||||
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||||
if (size == 0) return [0, "B"];
|
if (size == 0) return [0, "B"];
|
||||||
const i = parseInt(Math.floor(Math.log(size) / Math.log(1024)));
|
const i = parseInt(Math.floor(Math.log(size) / Math.log(1024)));
|
||||||
return [Math.round(size / Math.pow(1024, i), 2), sizes[i]];
|
ratio = 1
|
||||||
|
if (i >= 3) {
|
||||||
|
ratio = 100
|
||||||
|
}
|
||||||
|
return [Math.round(size * ratio / Math.pow(1024, i), 2) / ratio, sizes[i]];
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDuration(seconds) {
|
function formatDuration(seconds) {
|
||||||
|
|||||||
Reference in New Issue
Block a user