MCPcopy Create free account
hub / github.com/ScattrdBlade/bigFileUpload / formatBytes

Function formatBytes

index.tsx:171–184  ·  view source on GitHub ↗
(bytes: number)

Source from the content-addressed store, hash-verified

169}
170
171function formatBytes(bytes: number): string {
172 if (!bytes) return "";
173
174 const units = ["B", "KB", "MB", "GB"];
175 let value = bytes;
176 let unitIndex = 0;
177
178 while (value >= 1024 && unitIndex < units.length - 1) {
179 value /= 1024;
180 unitIndex++;
181 }
182
183 return `${value.toFixed(value >= 10 || unitIndex === 0 ? 0 : 1)} ${units[unitIndex]}`;
184}
185
186const ProgressBarInner = () => {
187 const [state, setState] = useState(getUploadState);

Callers 1

ProgressBarInnerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected