Download src/cli/shared/parse-port.ts from shimen/shinclaw: direct link, hf CLI and curl.
- Browser
- Download file 456 Bytes
-
https://huggingface.co/spaces/shimen/shinclaw/resolve/main/src/cli/shared/parse-port.ts
- Command line
-
hf download hf://spaces/shimen/shinclaw/src/cli/shared/parse-port.ts
-
curl -L -o parse-port.ts https://huggingface.co/spaces/shimen/shinclaw/resolve/main/src/cli/shared/parse-port.ts
456 Bytes
| export function parsePort(raw: unknown): number | null { | |
| if (raw === undefined || raw === null) { | |
| return null; | |
| } | |
| const value = | |
| typeof raw === "string" | |
| ? raw | |
| : typeof raw === "number" || typeof raw === "bigint" | |
| ? raw.toString() | |
| : null; | |
| if (value === null) { | |
| return null; | |
| } | |
| const parsed = Number.parseInt(value, 10); | |
| if (!Number.isFinite(parsed) || parsed <= 0) { | |
| return null; | |
| } | |
| return parsed; | |
| } | |