arrivals/departures: opt.stopovers for previous/next stopovers, docs 📝

This commit is contained in:
Jannis R 2018-12-27 20:17:23 +01:00
parent c70a851249
commit e867dac2ab
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 11 additions and 1 deletions

View file

@ -29,6 +29,7 @@ With `opt`, you can override the default options, which look like this:
duration: 10, // show departures for the next n minutes
stationLines: false, // parse & expose lines of the station?
remarks: true, // parse & expose hints & warnings?
stopovers: false, // fetch & parse previous/next stopovers?
// departures at related stations
// e.g. those that belong together on the metro map.
includeRelatedStations: true,

View file

@ -54,6 +54,7 @@ const createClient = (profile, userAgent, request = _request) => {
duration: 10, // show departures for the next n minutes
stationLines: false, // parse & expose lines of the station?
remarks: true, // parse & expose hints & warnings?
stopovers: false, // fetch & parse previous/next stopovers?
// departures at related stations
// e.g. those that belong together on the metro map.
includeRelatedStations: true
@ -73,7 +74,7 @@ const createClient = (profile, userAgent, request = _request) => {
dirLoc: dir,
jnyFltrL: [products],
dur: opt.duration,
getPasslist: false, // todo
getPasslist: !!opt.stopovers,
stbFltrEquiv: !opt.includeRelatedStations
}
})

View file

@ -63,6 +63,14 @@ const createParseArrOrDep = (profile, opt, data, prefix) => {
.filter(rem => !!rem) // filter unparsable
}
if (opt.stopovers && d.stopL) {
const parse = profile.parseStopover(profile, opt, data, d.date)
// Filter stations the train passes without stopping, as this doesn't comply with FPTF (yet).
const stopovers = d.stopL.map(parse).filter(st => !st.passBy)
if (prefix === ARRIVAL) res.previousStopovers = stopovers
else if (prefix === DEPARTURE) res.nextStopovers = stopovers
}
return res
}