MCPcopy
hub / github.com/autobrr/qui / detectBytesUnit

Function detectBytesUnit

web/src/components/query-builder/LeafCondition.tsx:104–113  ·  view source on GitHub ↗
(bytes: number)

Source from the content-addressed store, hash-verified

102
103// Detect best bytes unit from value
104function detectBytesUnit(bytes: number): number {
105 const tib = 1024 * 1024 * 1024 * 1024;
106 const gib = 1024 * 1024 * 1024;
107 const mib = 1024 * 1024;
108 // Use magnitude-based detection so fractional values like "24.5 TiB" re-open as TiB,
109 // rather than being reduced to "GiB" due to exact divisibility.
110 if (bytes >= tib) return tib;
111 if (bytes >= gib) return gib;
112 return mib;
113}
114
115interface LeafConditionProps {
116 id: string;

Callers 1

LeafConditionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected