mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-01 22:26:04 +08:00
11 lines
454 B
TypeScript
11 lines
454 B
TypeScript
// Accepts inputs like "121.5", "121,500" or "118" and normalises to a valid
|
||
// VHF airband frequency string (118.000–136.975). Returns null when invalid so
|
||
// callers/UI can disable the action.
|
||
export function normalizeManualFreq(input: string): string | null {
|
||
const raw = input.trim().replace(',', '.')
|
||
if (!raw) return null
|
||
const num = Number(raw)
|
||
if (!Number.isFinite(num) || num < 118 || num >= 137) return null
|
||
return num.toFixed(3)
|
||
}
|