MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / formatFileSize

Function formatFileSize

packages/kilo-chat/src/utils.ts:14–29  ·  view source on GitHub ↗
(bytes: number)

Source from the content-addressed store, hash-verified

12}
13
14export function formatFileSize(bytes: number): string {
15 let value = bytes;
16 let unitIndex = 0;
17
18 while (value >= 1024 && unitIndex < FILE_SIZE_UNITS.length - 1) {
19 value /= 1024;
20 unitIndex += 1;
21 }
22
23 if (unitIndex === 0) {
24 return `${Math.round(value)} ${FILE_SIZE_UNITS[unitIndex]}`;
25 }
26
27 const rounded = Math.round(value * 100) / 100;
28 return `${rounded} ${FILE_SIZE_UNITS[unitIndex]}`;
29}
30
31export function remainingEditableAttachments(
32 originalAttachments: readonly AttachmentBlock[],

Callers 8

AttachmentPreviewChipFunction · 0.90
FileChipFunction · 0.90
MessageInputFunction · 0.90
MessageAttachmentFunction · 0.90
AttachmentChipFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected