(raw: string | undefined)
| 230 | * caller can apply the format-dependent default (0 = infinite for gif). |
| 231 | */ |
| 232 | export function parseGifLoopArg(raw: string | undefined): GifLoopParseResult { |
| 233 | if (raw === undefined) return { ok: true, value: undefined }; |
| 234 | const trimmed = raw.trim(); |
| 235 | if (trimmed.length === 0) { |
| 236 | return { ok: false, message: "GIF loop count must not be empty." }; |
| 237 | } |
| 238 | const parsed = Number(trimmed); |
| 239 | if (!Number.isInteger(parsed) || parsed < 0 || parsed > 65_535) { |
| 240 | return { |
| 241 | ok: false, |
| 242 | message: `Got "${raw}". GIF loop count must be an integer between 0 and 65535.`, |
| 243 | }; |
| 244 | } |
| 245 | return { ok: true, value: parsed }; |
| 246 | } |
no outgoing calls
no test coverage detected