MCPcopy
hub / github.com/codeaashu/claude-code / formatFileSize

Function formatFileSize

src/utils/format.ts:9–23  ·  view source on GitHub ↗
(sizeInBytes: number)

Source from the content-addressed store, hash-verified

7 * @example formatFileSize(1536) → "1.5KB"
8 */
9export function formatFileSize(sizeInBytes: number): string {
10 const kb = sizeInBytes / 1024
11 if (kb < 1) {
12 return `${sizeInBytes} bytes`
13 }
14 if (kb < 1024) {
15 return `${kb.toFixed(1).replace(/\.0$/, '')}KB`
16 }
17 const mb = kb / 1024
18 if (mb < 1024) {
19 return `${mb.toFixed(1).replace(/\.0$/, '')}MB`
20 }
21 const gb = mb / 1024
22 return `${gb.toFixed(1).replace(/\.0$/, '')}GB`
23}
24
25/**
26 * 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