UNPKG

hk-bus-eta

Version:

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

53 lines (52 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const utils_1 = require("./utils"); function fetchEtas({ freq, seq, holidays, serviceDayMap, }) { if (seq >= 1) return Promise.resolve([]); const now = new Date(); return Promise.resolve((0, utils_1.getUpcomingFerry)({ holidays, serviceDayMap, freq, date: new Date() }) .filter((v) => new Date(v).getTime() - now.getTime() < 180 * 60 * 1000) .map((eta) => ({ eta: eta, remark: { zh: "預定班次", en: "Scheduled", }, dest: { zh: "", en: "", }, co: "fortuneferry", }))); /* * the official API is broken most of the time, keep it for reference return fetch( `https://www.hkkfeta.com/opendata/eta/${route.slice(2)}/${bound === "I" ? "inbound" : "outbound"}`, { cache: isSafari ? "default" : "no-store", }, ) .then((response) => response.json()) .then(({ data }) => { if (!data) return []; return data .map(({ETA}: any) => { return { eta: ETA, remark: { zh: "", en: "", }, dest: { zh: "", en: "", }, co: "hkkf", } }); }); */ } exports.default = fetchEtas; //# sourceMappingURL=hkkf.js.map