MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / formatFileSize

Function formatFileSize

source code/utils/format.ts:11–25  ·  view source on GitHub ↗
(sizeInBytes: number)

Source from the content-addressed store, hash-verified

9 * @example formatFileSize(1536) → "1.5KB"
10 */
11export function formatFileSize(sizeInBytes: number): string {
12 const kb = sizeInBytes / 1024
13 if (kb < 1) {
14 return `${sizeInBytes} bytes`
15 }
16 if (kb < 1024) {
17 return `${kb.toFixed(1).replace(/\.0$/, '')}KB`
18 }
19 const mb = kb / 1024
20 if (mb < 1024) {
21 return `${mb.toFixed(1).replace(/\.0$/, '')}MB`
22 }
23 const gb = mb / 1024
24 return `${gb.toFixed(1).replace(/\.0$/, '')}GB`
25}
26
27/**
28 * Formats milliseconds as seconds with 1 decimal place (e.g. `1234` → `"1.2s"`).

Callers 15

promptFunction · 0.85
callInnerFunction · 0.85
renderToolResultMessageFunction · 0.85
_tempFunction · 0.85
validateInputFunction · 0.85
callFunction · 0.85
renderToolResultMessageFunction · 0.85
MemoryUsageIndicatorFunction · 0.85
ShellProgressMessageFunction · 0.85
AttachmentMessageFunction · 0.85
ShellOutputContentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected