journeyPart: passedStations option

This commit is contained in:
Jannis R 2017-12-17 20:33:04 +01:00
parent 374fd6120a
commit aeac22b569
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 8 additions and 4 deletions

View file

@ -24,7 +24,8 @@ With `opt`, you can override the default options, which look like this:
```js
{
when: new Date()
when: new Date(),
passedStations: true // return stations on the way?
}
```

View file

@ -159,6 +159,9 @@ const createClient = (profile) => {
}
const journeyPart = (ref, lineName, opt = {}) => {
opt = Object.assign({
passedStations: true // return stations on the way?
}, opt)
opt.when = opt.when || new Date()
return request(profile, {
@ -179,7 +182,7 @@ const createClient = (profile) => {
arr: maxBy(d.journey.stopL, 'idx'),
jny: d.journey
}
return parse(d.journey, part)
return parse(d.journey, part, !!opt.passedStations)
})
}

View file

@ -13,7 +13,7 @@ const createParseJourneyPart = (profile, stations, lines, remarks) => {
// todo: what is pt.jny.dirFlg?
// todo: how does pt.freq work?
// todo: what is pt.himL?
const parseJourneyPart = (j, pt) => { // j = journey, pt = part
const parseJourneyPart = (j, pt, passed = true) => { // j = journey, pt = part
const dep = profile.parseDateTime(profile, j.date, pt.dep.dTimeR || pt.dep.dTimeS)
const arr = profile.parseDateTime(profile, j.date, pt.arr.aTimeR || pt.arr.aTimeS)
const res = {
@ -41,7 +41,7 @@ const createParseJourneyPart = (profile, stations, lines, remarks) => {
if (pt.dep.dPlatfS) res.departurePlatform = pt.dep.dPlatfS
if (pt.arr.aPlatfS) res.arrivalPlatform = pt.arr.aPlatfS
if (pt.jny.stopL) {
if (passed && pt.jny.stopL) {
const parse = profile.parseStopover(profile, stations, lines, remarks, j)
res.passed = pt.jny.stopL.map(parse)
}