mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-19 11:26:02 +00:00
9 lines
300 B
TypeScript
9 lines
300 B
TypeScript
export function parsePort(value: string, option = "--port"): number {
|
|
const message = `${option} must be an integer between 1 and 65535`;
|
|
if (!/^\d+$/.test(value)) throw new Error(message);
|
|
|
|
const port = Number(value);
|
|
if (port < 1 || port > 65535) throw new Error(message);
|
|
return port;
|
|
}
|