From c9514665971cc3990cb68892fc40eb49b55acbeb Mon Sep 17 00:00:00 2001 From: McToel Date: Wed, 19 Feb 2025 00:17:48 +0100 Subject: [PATCH] No async in new Promise --- index.js | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index fd63c644..8ee0fddd 100644 --- a/index.js +++ b/index.js @@ -26,23 +26,24 @@ const validateLocation = (loc, name = 'location') => { } }; -const loadEnrichedStationData = (profile) => new Promise(async (resolve, reject) => { - const { default: readStations} = await import('db-hafas-stations'); - const items = {}; - readStations.full() - .on('data', (station) => { - items[station.id] = station; - items[station.name] = station; - }) - .once('end', () => { - if (profile.DEBUG) { - console.log('Loaded station index.'); - } - resolve(items); - }) - .once('error', (err) => { - reject(err); - }); +const loadEnrichedStationData = (profile) => new Promise((resolve, reject) => { + import('db-hafas-stations').then(m => { + const items = {}; + m.default.full() + .on('data', (station) => { + items[station.id] = station; + items[station.name] = station; + }) + .once('end', () => { + if (profile.DEBUG) { + console.log('Loaded station index.'); + } + resolve(items); + }) + .once('error', (err) => { + reject(err); + }); + }); }); const createClient = (profile, userAgent, opt = {}) => {