MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / parseSizeInput

Function parseSizeInput

banana/banana.ts:138–161  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

136 const unit = match[2] || "mb";
137 const multiplier =
138 unit === "gb"
139 ? 1024 * 1024 * 1024
140 : unit === "mb"
141 ? 1024 * 1024
142 : unit === "kb"
143 ? 1024
144 : 1;
145
146 const bytes = Math.round(value * multiplier);
147 if (!Number.isFinite(bytes) || bytes <= 0) return null;
148 return bytes;
149}
150
151function normalizeMaxBytes(bytes: number | string | null | undefined): number {
152 const numeric = typeof bytes === "number" ? bytes : Number(bytes);
153 if (!Number.isFinite(numeric) || numeric <= 0) {
154 return DEFAULT_MAX_IMAGE_BYTES;
155 }
156 const rounded = Math.round(numeric);
157 if (rounded < MIN_ALLOWED_IMAGE_BYTES) {
158 return MIN_ALLOWED_IMAGE_BYTES;
159 }
160 if (rounded > MAX_ALLOWED_IMAGE_BYTES) {
161 return MAX_ALLOWED_IMAGE_BYTES;
162 }
163 return rounded;
164}

Callers 1

handleConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected