MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / formatBytes

Function formatBytes

packages/app-core/src/components/NoteList.tsx:43–50  ·  view source on GitHub ↗
(bytes: number)

Source from the content-addressed store, hash-verified

41}
42
43function formatBytes(bytes: number): string {
44 if (bytes < 1024) return `${bytes} B`
45 if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(bytes >= 10 * 1024 ? 0 : 1)} KB`
46 if (bytes < 1024 * 1024 * 1024) {
47 return `${(bytes / (1024 * 1024)).toFixed(bytes >= 10 * 1024 * 1024 ? 0 : 1)} MB`
48 }
49 return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`
50}
51
52const ASSET_LAYOUT_KEY = 'zen:assets-layout:v1'
53type AssetLayout = 'grid' | 'list'

Callers 3

FolderAssetRowFunction · 0.70
AssetCardFunction · 0.70
AssetRowFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected