MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / formatBytes

Function formatBytes

packages/aws-lambda/scripts/_formatBytes.ts:10–15  ·  view source on GitHub ↗
(bytes: number)

Source from the content-addressed store, hash-verified

8 * don't conflate them.
9 */
10export function formatBytes(bytes: number): string {
11 if (bytes < 1024) return `${bytes} B`;
12 if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KiB`;
13 if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MiB`;
14 return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GiB`;
15}

Callers 2

mainFunction · 0.70
mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected