mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
pass in part parsing fn, expose departure refs, 1.2.0
This commit is contained in:
parent
87d5f004c0
commit
dd7eef94ac
2 changed files with 8 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "hafas-client",
|
"name": "hafas-client",
|
||||||
"description": "JavaScript client for HAFAS mobile APIs.",
|
"description": "JavaScript client for HAFAS mobile APIs.",
|
||||||
"version": "1.1.0",
|
"version": "1.2.0",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"files": ["index.js", "parse.js", "stringify.js"],
|
"files": ["index.js", "parse.js", "stringify.js"],
|
||||||
"author": "Jannis R <mail@jannisr.de>",
|
"author": "Jannis R <mail@jannisr.de>",
|
||||||
|
|
13
parse.js
13
parse.js
|
@ -66,7 +66,7 @@ const operator = (a) => ({
|
||||||
|
|
||||||
// s = stations, ln = lines, r = remarks, c = connection
|
// s = stations, ln = lines, r = remarks, c = connection
|
||||||
const stopover = (tz, s, ln, r, c) => (st) => {
|
const stopover = (tz, s, ln, r, c) => (st) => {
|
||||||
const result = {station: s[parseInt(st.locX)]}
|
const result = {station: s[parseInt(st.locX)]}
|
||||||
if (st.aTimeR || st.aTimeS) {
|
if (st.aTimeR || st.aTimeS) {
|
||||||
result.arrival = dateTime(tz, c.date, st.aTimeR || st.aTimeS).format()
|
result.arrival = dateTime(tz, c.date, st.aTimeR || st.aTimeS).format()
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ const applyRemark = (s, ln, r, c) => (rm) => null
|
||||||
// todo: pt.dep.dProgType, pt.arr.dProgType
|
// todo: pt.dep.dProgType, pt.arr.dProgType
|
||||||
// todo: what is pt.jny.dirFlg?
|
// todo: what is pt.jny.dirFlg?
|
||||||
// todo: how does pt.freq work?
|
// todo: how does pt.freq work?
|
||||||
// s = stations, ln = lines, r = remarks, c = connection
|
// tz = timezone, s = stations, ln = lines, r = remarks, c = connection
|
||||||
const part = (tz, s, ln, r, c) => (pt) => {
|
const part = (tz, s, ln, r, c) => (pt) => {
|
||||||
const result = {
|
const result = {
|
||||||
origin: Object.assign({}, s[parseInt(pt.dep.locX)])
|
origin: Object.assign({}, s[parseInt(pt.dep.locX)])
|
||||||
|
@ -127,9 +127,9 @@ const part = (tz, s, ln, r, c) => (pt) => {
|
||||||
// todo: c.conSubscr
|
// todo: c.conSubscr
|
||||||
// todo: c.trfRes x vbb-parse-ticket
|
// todo: c.trfRes x vbb-parse-ticket
|
||||||
// todo: use computed information from part
|
// todo: use computed information from part
|
||||||
// s = stations, ln = lines, r = remarks
|
// s = stations, ln = lines, r = remarks, p = parsePart
|
||||||
const journey = (tz, s, ln, r) => (c) => {
|
const journey = (tz, s, ln, r, p = part) => (c) => {
|
||||||
const parts = c.secL.map(part(tz, s, ln, r, c))
|
const parts = c.secL.map(p(tz, s, ln, r, c))
|
||||||
return {
|
return {
|
||||||
parts
|
parts
|
||||||
, origin: parts[0].origin
|
, origin: parts[0].origin
|
||||||
|
@ -145,7 +145,8 @@ const journey = (tz, s, ln, r) => (c) => {
|
||||||
// tz = timezone, s = stations, ln = lines, r = remarks
|
// tz = timezone, s = stations, ln = lines, r = remarks
|
||||||
const departure = (tz, s, ln, r) => (d) => {
|
const departure = (tz, s, ln, r) => (d) => {
|
||||||
const result = {
|
const result = {
|
||||||
station: s[parseInt(d.stbStop.locX)]
|
ref: d.jid
|
||||||
|
, station: s[parseInt(d.stbStop.locX)]
|
||||||
, when: dateTime(tz, d.date, d.stbStop.dTimeR || d.stbStop.dTimeS).format()
|
, when: dateTime(tz, d.date, d.stbStop.dTimeR || d.stbStop.dTimeS).format()
|
||||||
, direction: d.dirTxt
|
, direction: d.dirTxt
|
||||||
, line: ln[parseInt(d.prodX)]
|
, line: ln[parseInt(d.prodX)]
|
||||||
|
|
Loading…
Add table
Reference in a new issue