MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / formatMemory

Function formatMemory

packages/db/src/clickhouse/migration.ts:485–494  ·  view source on GitHub ↗
(bytes: number)

Source from the content-addressed store, hash-verified

483 .then((res) => res.json());
484
485 const formatMemory = (bytes: number) => {
486 const units = ['B', 'KB', 'MB', 'GB'];
487 let size = bytes;
488 let unitIndex = 0;
489 while (size >= 1024 && unitIndex < units.length - 1) {
490 size /= 1024;
491 unitIndex++;
492 }
493 return `${Math.round(size * 100) / 100}${units[unitIndex]}`;
494 };
495
496 const formatNumber = (num: number) => {
497 return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');

Callers 1

checkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected