UNPKG

hk-bus-eta-skpracta

Version:

Query the ETA (Estimated Time of Arrival) of HK Bus/Minibus/MTR/Lightrail (skpracta flavored)

30 lines 1.08 kB
import { isSafari } from "./utils"; export default function fetchEtas({ gtfsId, stopId, bound, seq, }) { return fetch(`https://data.etagmb.gov.hk/eta/route-stop/${gtfsId}/${stopId}`, { cache: isSafari ? "default" : "no-store", }) .then((response) => response.json()) .then(({ data }) => data .filter(({ route_seq }) => (bound === "O" && route_seq === 1) || (bound === "I" && route_seq === 2)) .filter(({ stop_seq }) => stop_seq === seq + 1) .reduce((acc, { eta }) => [ ...acc, ...eta.map((data) => { var _a, _b; return ({ eta: data.timestamp, remark: { zh: (_a = data.remarks_tc) !== null && _a !== void 0 ? _a : "", en: (_b = data.remarks_en) !== null && _b !== void 0 ? _b : "", }, dest: { zh: "", en: "", }, co: "gmb", }); }), ], [])); } //# sourceMappingURL=gmb.js.map