db-vendo-client/parse/journey.js

36 lines
886 B
JavaScript
Raw Normal View History

2017-11-11 22:35:41 +01:00
'use strict'
2017-11-20 15:43:13 +01:00
const createParseJourneyPart = require('./journey-part')
2017-11-11 22:35:41 +01:00
const clone = obj => Object.assign({}, obj)
2017-11-12 01:23:34 +01:00
const createParseJourney = (profile, stations, lines, remarks) => {
2017-11-20 15:43:13 +01:00
const parsePart = createParseJourneyPart(profile, stations, lines, remarks)
2017-11-11 22:35:41 +01:00
// todo: c.sDays
// todo: c.dep.dProgType, c.arr.dProgType
// todo: c.conSubscr
// todo: c.trfRes x vbb-parse-ticket
// todo: use computed information from part
2017-11-12 01:23:34 +01:00
const parseJourney = (j) => {
const parts = j.secL.map(part => parsePart(j, part))
const res = {
parts,
origin: parts[0].origin,
destination: parts[parts.length - 1].destination,
departure: parts[0].departure,
arrival: parts[parts.length - 1].arrival
2017-11-11 22:35:41 +01:00
}
if (parts.some(p => p.cancelled)) {
res.cancelled = true
res.departure = res.arrival = null
}
return res
2017-11-11 22:35:41 +01:00
}
return parseJourney
}
module.exports = createParseJourney