@signalk/nmea0183-signalk
Version:
A node.js/javascript parser for NMEA0183 sentences. Sentences are parsed to Signal K format.
26 lines • 1.36 kB
TypeScript
/**
* NMEA-field → typed-union boundary helpers.
*
* Raw NMEA fields are `string` at parse time; TypeScript can't narrow them
* to the tight `Pole` / `UnitFormat` unions that `@signalk/nmea0183-utilities`
* exposes without runtime validation. Each helper below does that validation
* and returns `null` when the field doesn't match the spec letter set, so
* malformed sentences produce a `null` delta value instead of bubbling a
* `TypeError` up through the Parser.
*/
import type { Pole, UnitFormat } from '@signalk/nmea0183-utilities';
/** Narrow a raw NMEA cardinal-letter field to `Pole`, or `null` if invalid. */
export declare function toPole(raw: string | undefined | null): Pole | null;
/** Narrow a raw NMEA unit-letter field to `UnitFormat`, or `null` if invalid. */
export declare function toUnit(raw: string | undefined | null): UnitFormat | null;
/**
* `utils.coordinate` with pole-field validation. Returns `null` when the
* pole letter isn't `N` / `S` / `E` / `W` rather than throwing.
*/
export declare function coord(value: string, pole: string): number | null;
/**
* `utils.magneticVariation` with pole-field validation. Returns `null`
* when the pole letter isn't valid rather than throwing.
*/
export declare function magVar(degrees: number | string, pole: string): number | null;
//# sourceMappingURL=nmea-casts.d.ts.map