implemented save file compression in browser
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
const KILOBYTE = 1024
|
||||
const MEGABYTE = 1024 * KILOBYTE
|
||||
|
||||
/**
|
||||
* Formats a byte count for error messages and status lines, e.g. "12.3 MB".
|
||||
*/
|
||||
export function formatBytes(bytes: number): string {
|
||||
if (bytes >= MEGABYTE) return `${(bytes / MEGABYTE).toFixed(1)} MB`
|
||||
if (bytes >= KILOBYTE) return `${(bytes / KILOBYTE).toFixed(1)} KB`
|
||||
return `${bytes} B`
|
||||
}
|
||||
Reference in New Issue
Block a user