MCPcopy
hub / github.com/simstudioai/sim / prettySize

Function prettySize

apps/sim/app/api/files/parse/route.ts:1130–1137  ·  view source on GitHub ↗

* Format bytes to human readable size

(bytes: number)

Source from the content-addressed store, hash-verified

1128 * Format bytes to human readable size
1129 */
1130function prettySize(bytes: number): string {
1131 if (bytes === 0) return '0 Bytes'
1132
1133 const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']
1134 const i = Math.floor(Math.log(bytes) / Math.log(1024))
1135
1136 return `${Number.parseFloat((bytes / 1024 ** i).toFixed(2))} ${sizes[i]}`
1137}
1138
1139/**
1140 * Create a formatted message for PDF content

Callers 7

handleExternalUrlFunction · 0.85
handleCloudFileFunction · 0.85
handleLocalFileFunction · 0.85
createPdfFallbackMessageFunction · 0.85
createPdfFailureMessageFunction · 0.85

Calls 1

logMethod · 0.80

Tested by

no test coverage detected