MCPcopy Index your code
hub / github.com/simstudioai/sim / formatFileSize

Function formatFileSize

apps/sim/lib/api/contracts/storage-transfer.ts:22–29  ·  view source on GitHub ↗
(bytes: number)

Source from the content-addressed store, hash-verified

20const jsonResponseSchema = z.unknown()
21
22function formatFileSize(bytes: number): string {
23 if (!Number.isFinite(bytes) || bytes <= 0) return '0 Bytes'
24 const k = 1024
25 const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']
26 const i = Math.min(Math.floor(Math.log(bytes) / Math.log(k)), sizes.length - 1)
27 const value = bytes / k ** i
28 return `${value.toFixed(value >= 100 || i === 0 ? 0 : 1)} ${sizes[i]}`
29}
30
31const multipartPartUrlSchema = z.object({
32 partNumber: z.number(),

Callers 1

Calls 1

logMethod · 0.80

Tested by

no test coverage detected