MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / humanizeBytes

Function humanizeBytes

console/src/utils/format.ts:38–53  ·  view source on GitHub ↗
(bytes: bigint)

Source from the content-addressed store, hash-verified

36const MAX_LAG_MS = 86_400_000;
37
38export function humanizeBytes(bytes: bigint): {
39 value: number;
40 unit: ByteUnit;
41} {
42 if (bytes < kilobyte) {
43 return { value: Number(bytes), unit: "B" };
44 } else if (bytes < megabyte) {
45 return { value: Number(bytes) / Number(kilobyte), unit: "KB" };
46 } else if (bytes < gigabyte) {
47 return { value: Number(bytes) / Number(megabyte), unit: "MB" };
48 } else if (bytes < terabyte) {
49 return { value: Number(bytes) / Number(gigabyte), unit: "GB" };
50 } else {
51 return { value: Number(bytes) / Number(terabyte), unit: "TB" };
52 }
53}
54
55export const formatBytesShort = (bytes: bigint) => {
56 const { value, unit } = humanizeBytes(bytes);

Callers 2

formatBytesShortFunction · 0.85
formatMemoryUsageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected