MCPcopy Create free account
hub / github.com/Roy3838/Observer / formatBytes

Function formatBytes

app/src/components/ModelHub.tsx:76–83  ·  view source on GitHub ↗
(bytes: number, decimals = 2)

Source from the content-addressed store, hash-verified

74];
75
76const formatBytes = (bytes: number, decimals = 2) => {
77 if (!+bytes) return '0 Bytes';
78 const k = 1024;
79 const dm = decimals < 0 ? 0 : decimals;
80 const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
81 const i = Math.floor(Math.log(bytes) / Math.log(k));
82 return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
83};
84
85const TAB_COLORS: Record<TabColor, { active: string; dot: string }> = {
86 green: { active: 'bg-white text-gray-800 shadow-sm', dot: 'bg-gray-500' },

Callers 2

ModelHubFunction · 0.70
renderProgressRowFunction · 0.70

Calls 1

logMethod · 0.45

Tested by

no test coverage detected