diff --git a/docs/journey-part.md b/docs/journey-part.md index ad9edf90..b08d300a 100644 --- a/docs/journey-part.md +++ b/docs/journey-part.md @@ -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? } ``` diff --git a/index.js b/index.js index f57ec057..ab19dfd4 100644 --- a/index.js +++ b/index.js @@ -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) }) } diff --git a/parse/journey-part.js b/parse/journey-part.js index 198c5fc6..c1d8648b 100644 --- a/parse/journey-part.js +++ b/parse/journey-part.js @@ -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) }