MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / convertFileSize

Function convertFileSize

frontend/src/tools/fileSize.ts:1–10  ·  view source on GitHub ↗
(e: string)

Source from the content-addressed store, hash-verified

1export const convertFileSize = (e: string) =>
2 e == "0"
3 ? "0 B"
4 : `${(
5 parseFloat(e) / Math.pow(1024, Math.floor(Math.log(parseFloat(e)) / Math.log(1024)))
6 ).toFixed(2)} ${
7 ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][
8 Math.floor(Math.log(parseFloat(e)) / Math.log(1024))
9 ]
10 }`;

Callers 1

startUploadFunction · 0.90

Calls 1

logMethod · 0.80

Tested by

no test coverage detected