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 { 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 = {}) => {