MCPcopy Create free account
hub / github.com/error311/FileRise / formatBytes

Function formatBytes

public/js/transferProgress.js:26–32  ·  view source on GitHub ↗
(bytes)

Source from the content-addressed store, hash-verified

24}
25
26function formatBytes(bytes) {
27 if (!Number.isFinite(bytes) || bytes < 0) return '0 B';
28 if (bytes < 1024) return `${Math.round(bytes)} B`;
29 if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
30 if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
31 return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
32}
33
34function formatSpeed(bps) {
35 return `${formatBytes(bps)}/s`;

Callers 2

formatSpeedFunction · 0.70
renderJobFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected