MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / formatDocSize

Function formatDocSize

packages/baseai/src/utils/memory/lib.ts:53–65  ·  view source on GitHub ↗
(bytes: number)

Source from the content-addressed store, hash-verified

51 * @returns A string representing the formatted size.
52 */
53export function formatDocSize(bytes: number): string {
54 if (bytes === 0) return '0 bytes';
55
56 if (bytes < 1024) {
57 return bytes.toFixed(2) + ' bytes';
58 } else if (bytes < 1024 * 1024) {
59 const fileSizeInKB = bytes / 1024;
60 return fileSizeInKB.toFixed(2) + ' KB';
61 } else {
62 const fileSizeInMB = bytes / (1024 * 1024);
63 return fileSizeInMB.toFixed(2) + ' MB';
64 }
65}
66
67/**
68 * Validates the given memory name.

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected