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

Function formatBytes

packages/app-core/src/components/SettingsModal.tsx:285–296  ·  view source on GitHub ↗
(bytes: number | null)

Source from the content-addressed store, hash-verified

283}
284
285function formatBytes(bytes: number | null): string | null {
286 if (bytes == null || !Number.isFinite(bytes) || bytes <= 0) return null
287 const units = ['B', 'KB', 'MB', 'GB']
288 let value = bytes
289 let unit = units[0]
290 for (let i = 1; i < units.length && value >= 1024; i += 1) {
291 value /= 1024
292 unit = units[i]
293 }
294 const rounded = value >= 100 ? value.toFixed(0) : value >= 10 ? value.toFixed(1) : value.toFixed(2)
295 return `${rounded} ${unit}`
296}
297
298function formatReleaseNotesForDisplay(notes: string | null): string | null {
299 if (!notes) return null

Callers 1

SettingsModalFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected