commit 79ef3818195ae160936d8cac9f085637887db926
parent 9c1be8aeb5f2e753d15643d12e43686016daccbe
Author: Yureka <yuka@yuka.dev>
Date: Mon, 13 Jan 2025 21:05:47 +0100
parent 9c1be8aeb5f2e753d15643d12e43686016daccbe
Author: Yureka <yuka@yuka.dev>
Date: Mon, 13 Jan 2025 21:05:47 +0100
load hafas-client on demand
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/hafas_client.js b/src/hafas_client.js @@ -1,11 +1,9 @@ const clients = {}; +let createHafasClient; export let client; -import { createClient as createHafasClient } from "hafas-client"; import { createClient as createVendoClient } from "db-vendo-client"; - import { profile as dbnavProfile } from "db-vendo-client/p/dbnav"; -import { profile as nahshProfile } from "hafas-client/p/nahsh"; export const getHafasClient = async profileName => { if (!clients[profileName]) { @@ -20,11 +18,13 @@ export const getHafasClient = async profileName => { profile = bvgProfile; break; case "nahsh": + const { profile: nahshProfile } = await import('hafas-client/p/nahsh'); profile = nahshProfile; break; default: throw "Unknown profile name: " + profileName; } + if (!createHafasClient) createHafasClient = (await import("hafas-client")).createClient; clients[profileName] = createHafasClient(profile, "trainsearch"); }