187 files
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { formatNumber } from "../styles";
|
||||
|
||||
/** Human-readable byte size (B / KB / MB) for document storage figures. */
|
||||
export function formatBytes(bytes: number | undefined): string {
|
||||
export function formatBytes(bytes: number | undefined, lang?: string): string {
|
||||
const b = bytes ?? 0;
|
||||
if (b < 1024) return `${b} B`;
|
||||
if (b < 1024 * 1024) return `${(b / 1024).toFixed(1)} KB`;
|
||||
return `${(b / (1024 * 1024)).toFixed(1)} MB`;
|
||||
if (b < 1024 * 1024) return `${formatNumber(b / 1024, lang, 1)} KB`;
|
||||
return `${formatNumber(b / (1024 * 1024), lang, 1)} MB`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user