mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
No async in new Promise
This commit is contained in:
parent
f1d226e9c8
commit
c951466597
1 changed files with 18 additions and 17 deletions
35
index.js
35
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 = {}) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue