MCPcopy
hub / github.com/guangzhengli/ChatFiles / humanFileSize

Function humanFileSize

utils/app/files.ts:1–9  ·  view source on GitHub ↗
(size: number)

Source from the content-addressed store, hash-verified

1export const humanFileSize = (size: number): string => {
2 const units = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
3 let i = 0;
4 while (size >= 1024 && i < units.length - 1) {
5 size /= 1024;
6 i++;
7 }
8 return `${size.toFixed(0)} ${units[i]}`;
9}

Callers 2

Chat.tsxFile · 0.90
validateFileFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected