hk-bus-eta
Version:
Query the ETA (Estimated Time of Arrival) of HK Bus/Minibus/MTR/Lightrail
50 lines (49 loc) • 1.39 kB
JavaScript
import { getUpcomingFerry } from "./utils";
export default function fetchEtas({ freq, seq, holidays, serviceDayMap, }) {
if (seq >= 1)
return Promise.resolve([]);
const now = new Date();
return Promise.resolve(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",
}
});
});
*/
}
//# sourceMappingURL=hkkf.js.map