Vary number of decimals of file sizes
This commit is contained in:
parent
8c4a7cb2be
commit
1364ba5784
3 changed files with 13 additions and 11 deletions
|
@ -2,6 +2,9 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
import filesize from 'filesize';
|
||||
|
||||
export function formatFileSize(size: number, decimals = 0): string {
|
||||
return filesize(size, { round: decimals });
|
||||
// Intentional, `filesize` uses `jedec` standard by default
|
||||
const MB = 1000 * 1000;
|
||||
|
||||
export function formatFileSize(size: number): string {
|
||||
return filesize(size, { round: size < MB ? 0 : 1 });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue