MCPcopy Index your code
hub / github.com/Tencent/CodeAnalysis / bytesToSize

Function bytesToSize

web/packages/shared/util/size.ts:12–20  ·  view source on GitHub ↗
(bytes: number)

Source from the content-addressed store, hash-verified

10 * @returns 格式化后字节大小
11 */
12export const bytesToSize = (bytes: number) => {
13 if (typeof bytes !== 'number') {
14 return '-';
15 }
16 if (bytes === 0) return '0 B';
17 const k = 1024;
18 const i = Math.floor(Math.log(bytes) / Math.log(k));
19 return `${(bytes / (k ** i)).toPrecision(3)} ${sizes[i]}`;
20};

Callers 3

ProcessFunction · 0.90
ProcessFunction · 0.90
ProcessFunction · 0.90

Calls 1

logMethod · 0.45

Tested by

no test coverage detected