MCPcopy
hub / github.com/CapSoftware/Cap / parsePositiveInteger

Function parsePositiveInteger

apps/web/app/api/mobile/[...route]/route.ts:171–179  ·  view source on GitHub ↗
(
	value: string | undefined,
	fallback: number,
	max: number,
)

Source from the content-addressed store, hash-verified

169};
170
171const parsePositiveInteger = (
172 value: string | undefined,
173 fallback: number,
174 max: number,
175) => {
176 const parsed = Number(value);
177 if (!Number.isFinite(parsed) || parsed < 1) return fallback;
178 return Math.min(Math.trunc(parsed), max);
179};
180
181const getMetadataRecord = (metadata: unknown): Record<string, unknown> => {
182 if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {

Callers 1

route.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected