arrivals/departures: parse & expose platforms

This commit is contained in:
Jannis R 2018-06-27 17:17:04 +02:00
parent eeb9ec2535
commit d3815f80d7
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 14 additions and 0 deletions

View file

@ -10,6 +10,7 @@ This version is not fully backwords-compatible. Check out [the migration guide](
- ac9819b `arrivals()` method  [docs](arrivals.md)
- 21c273c `journeys()`/`journeyLeg()`: leg stopovers: parse & expose delays
- 021ae45 `journeys()`/`journeyLeg()`: leg stopovers: parse & expose platforms
- 84bce0c `arrivals()`/`departures()`: parse & expose platforms
- 85e0bdf `journeys()`: `startWithWalking` option with default `true`
### breaking changes 💥

View file

@ -37,6 +37,13 @@ const createParseArrOrDep = (profile, opt, data, prefix) => {
res.delay = Math.round((realtime - planned) / 1000)
} else res.delay = null
// todo: DRY with parseStopover
// todo: DRY with parseJourneyLeg
const pR = d.stbStop[prefix + 'PlatfR']
const pP = d.stbStop[prefix + 'PlatfS']
res.platform = pR || pP || null
// todo: `formerScheduledPlatform`
// todo: DRY with parseStopover
// todo: DRY with parseJourneyLeg
if (d.stbStop[prefix + 'Cncl']) {

View file

@ -243,6 +243,12 @@ const createValidateArrivalOrDeparture = (cfg) => {
a.strictEqual(typeof dep.delay, 'number', msg)
}
if (dep.platform !== null) {
const msg = name + '.platform must '
a.strictEqual(typeof dep.platform, 'string', msg + 'be a string')
a.ok(dep.platform, name + 'not be empty')
}
val.line(val, dep.line, name + '.line')
a.strictEqual(typeof dep.direction, 'string', name + '.direction must be a string')
a.ok(dep.direction, name + '.direction must not be empty')