UNPKG

@dylmye/flight-designator

Version:

Parse and construct flight designators - now with TypeScript

73 lines 2.73 kB
export interface IFlightDesignator { airlineCode?: string; flightNumber?: number; operationalSuffix?: string; /** Determine whether the input is a valid flight designator */ readonly isValid: () => boolean; /** Parses a flight designator */ readonly parse: (value: string) => this | null; /** Format the flight designator */ readonly toString: (spaces: boolean, pad: boolean) => string; } /** Validator object for Flight Designators */ export default class FlightDesignator implements IFlightDesignator { airlineCode?: string; flightNumber?: number; operationalSuffix?: string; constructor(airline?: string, number?: string, suffix?: string); /** * Flight designator pattern (IATA/ICAO) * NOTE: This pattern DOES NOT validate the flight number * (i.e. it does match invalid '0000' flight numbers) * * @static * @readonly */ static readonly pattern: RegExp; /** IATA/ICAO airline code pattern * @static * @readonly */ static readonly airlinePattern: RegExp; /** * Flight number pattern * NOTE: This regular expression checks for two things * by utilizing a lookahead: The first group checks (via the lookahead) * if the number is non-zero, the second whether it is between 1-4 chars long * * @static * @readonly */ static readonly flightPattern: RegExp; /** Operational suffix test pattern * @static * @readonly */ static readonly suffixPattern: RegExp; /** Determine whether the input is a valid flight designator * @static */ static readonly isValid: (designator: string) => boolean; /** Determines whether the input is a valid airline code * @static */ static readonly isValidAirlineCode: (airlineCode: string) => boolean; /** Determines whether the input is a valid flight number * @static */ static readonly isValidFlightNumber: (flightNumber: string) => boolean; /** Determine whether the input is a valid operational suffix * @static */ static readonly isValidSuffix: (suffix?: string | null | undefined) => boolean; /** Parses a flight designator * @static */ static readonly parse: (value: string) => FlightDesignator | null; /** Parses and formats a flight designator */ static readonly format: (value: string, spaces?: boolean, pad?: boolean) => string | undefined; readonly isValid: () => boolean; readonly parse: (value: string) => this; readonly toString: (spaces?: boolean, pad?: boolean) => string; } //# sourceMappingURL=flight-designator.d.ts.map