From ca5dd28ab60d78f42150460cbe9d4ed58d40afe4 Mon Sep 17 00:00:00 2001 From: Abhi <43648792+abhipatel12@users.noreply.github.com> Date: Fri, 25 Jul 2025 21:56:49 -0400 Subject: refactor(core): Centralize shell logic into ShellExecutionService (#4823) --- packages/core/src/utils/formatters.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 packages/core/src/utils/formatters.ts (limited to 'packages/core/src/utils/formatters.ts') diff --git a/packages/core/src/utils/formatters.ts b/packages/core/src/utils/formatters.ts new file mode 100644 index 00000000..ab02160e --- /dev/null +++ b/packages/core/src/utils/formatters.ts @@ -0,0 +1,16 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +export const formatMemoryUsage = (bytes: number): string => { + const gb = bytes / (1024 * 1024 * 1024); + if (bytes < 1024 * 1024) { + return `${(bytes / 1024).toFixed(1)} KB`; + } + if (bytes < 1024 * 1024 * 1024) { + return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; + } + return `${gb.toFixed(2)} GB`; +}; -- cgit v1.2.3