Function
parsePositiveInteger
(
value: string | undefined,
fallback: number,
max: number,
)
Source from the content-addressed store, hash-verified
| 169 | }; |
| 170 | |
| 171 | const 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 | |
| 181 | const getMetadataRecord = (metadata: unknown): Record<string, unknown> => { |
| 182 | if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) { |
Tested by
no test coverage detected