mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-24 07:39:36 +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 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 = {}) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue