MCPcopy Create free account
hub / github.com/LibPDF-js/core / formatBytes

Function formatBytes

examples/utils.ts:74–84  ·  view source on GitHub ↗
(bytes: number)

Source from the content-addressed store, hash-verified

72 * @returns Formatted string like "1.5 KB" or "2.3 MB"
73 */
74export function formatBytes(bytes: number): string {
75 if (bytes < 1024) {
76 return `${bytes} B`;
77 }
78
79 if (bytes < 1024 * 1024) {
80 return `${(bytes / 1024).toFixed(1)} KB`;
81 }
82
83 return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
84}

Callers 15

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected