MCPcopy Index your code
hub / github.com/ChartGPU/ChartGPU / formatBytes

Function formatBytes

examples/worker-rendering/main.ts:183–188  ·  view source on GitHub ↗
(bytes: number)

Source from the content-addressed store, hash-verified

181}
182
183function formatBytes(bytes: number): string {
184 if (bytes < 1024) return `${bytes} B`;
185 if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
186 if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
187 return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
188}
189
190function formatDuration(ms: number): string {
191 if (ms < 1000) return `${ms.toFixed(0)}ms`;

Callers 1

updateMetricsDisplayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected