No async in new Promise

This commit is contained in:
McToel 2025-02-19 00:17:48 +01:00
parent f1d226e9c8
commit c951466597

View file

@ -26,23 +26,24 @@ const validateLocation = (loc, name = 'location') => {
} }
}; };
const loadEnrichedStationData = (profile) => new Promise(async (resolve, reject) => { const loadEnrichedStationData = (profile) => new Promise((resolve, reject) => {
const { default: readStations} = await import('db-hafas-stations'); import('db-hafas-stations').then(m => {
const items = {}; const items = {};
readStations.full() m.default.full()
.on('data', (station) => { .on('data', (station) => {
items[station.id] = station; items[station.id] = station;
items[station.name] = station; items[station.name] = station;
}) })
.once('end', () => { .once('end', () => {
if (profile.DEBUG) { if (profile.DEBUG) {
console.log('Loaded station index.'); console.log('Loaded station index.');
} }
resolve(items); resolve(items);
}) })
.once('error', (err) => { .once('error', (err) => {
reject(err); reject(err);
}); });
});
}); });
const createClient = (profile, userAgent, opt = {}) => { const createClient = (profile, userAgent, opt = {}) => {