UNPKG

minotor

Version:

A lightweight client-side transit routing library.

62 lines (61 loc) 1.75 kB
import { Stop } from '../stops/stops.js'; import type { PickUpDropOffTypeString } from '../timetable/route.js'; import { Duration, Time } from '../timetable/time.js'; import type { RouteTypeString, TransferTypeString } from '../timetable/timetable.js'; export type ServiceRouteInfo = { type: RouteTypeString; name: string; }; export type BaseLeg = { from: Stop; to: Stop; }; export type Access = BaseLeg & { duration: Duration; }; export type Transfer = BaseLeg & { minTransferTime?: Duration; type: TransferTypeString; }; export type VehicleLeg = BaseLeg & { route: ServiceRouteInfo; departureTime: Time; arrivalTime: Time; pickUpType: PickUpDropOffTypeString; dropOffType: PickUpDropOffTypeString; }; export type Leg = Transfer | Access | VehicleLeg; /** * Represents a resolved route consisting of multiple legs, * which can be either vehicle legs or transfer legs. */ export declare class Route { legs: Leg[]; constructor(legs: Leg[]); /** * Calculates the departure time of the route. * * @returns The departure time of the route. * @throws If no vehicle leg is found in the route. */ departureTime(): Time; /** * Calculates the arrival time of the route. * * @returns The arrival time of the route. * @throws If no vehicle leg is found in the route. */ arrivalTime(): Time; /** * Calculates the total duration of the route. * * @returns The total duration of the route. */ totalDuration(): Duration; /** * Generates a human-readable string representation of the route. * * @returns A formatted string describing each leg of the route. */ toString(): string; }