From e98cec1734fa7881449189804b84b7bc07141135 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Mon, 3 Sep 2018 15:29:06 +0200 Subject: [PATCH] remove unused code, minor changes --- docs/journeys.md | 1 + index.js | 2 +- lib/request.js | 2 +- parse/hint.js | 188 ------------------------------------------- parse/journey-leg.js | 1 - 5 files changed, 3 insertions(+), 191 deletions(-) diff --git a/docs/journeys.md b/docs/journeys.md index 59efe021..d5f47ff9 100644 --- a/docs/journeys.md +++ b/docs/journeys.md @@ -46,6 +46,7 @@ With `opt`, you can override the default options, which look like this: earlierThan: null, // ref to get journeys earlier than the last query laterThan: null, // ref to get journeys later than the last query + results: 5, // how many journeys? via: null, // let journeys pass this station stopovers: false, // return stations on the way? diff --git a/index.js b/index.js index 3c3d1371..ee8be8d3 100644 --- a/index.js +++ b/index.js @@ -445,7 +445,7 @@ const createClient = (profile, userAgent, request = _request) => { } }) .then((d) => { - if (!Array.isArray(d.jnyL)) return [] + if (!Array.isArray(d.jnyL) || d.jnyL.length === 0) return [] const parse = profile.parseMovement(profile, opt, { locations: d.locations, diff --git a/lib/request.js b/lib/request.js index 50247888..1a8f1432 100644 --- a/lib/request.js +++ b/lib/request.js @@ -28,7 +28,7 @@ const md5 = input => createHash('md5').update(input).digest() const request = (profile, userAgent, opt, data) => { const body = profile.transformReqBody({ - lang: opt.language || 'en', + lang: opt.language || 'en', // todo: is it `eng` actually? svcReqL: [data] }) const req = profile.transformReq({ diff --git a/parse/hint.js b/parse/hint.js index 7dd6f045..403e5418 100644 --- a/parse/hint.js +++ b/parse/hint.js @@ -1,193 +1,5 @@ 'use strict' -const hints = Object.assign(Object.create(null), { - fb: { - type: 'hint', - code: 'bicycle-conveyance', - summary: 'bicycles conveyed' - }, - fr: { - type: 'hint', - code: 'bicycle-conveyance-reservation', - summary: 'bicycles conveyed, subject to reservation' - }, - nf: { - type: 'hint', - code: 'no-bicycle-conveyance', - summary: 'bicycles not conveyed' - }, - k2: { - type: 'hint', - code: '2nd-class-only', - summary: '2. class only' - }, - eh: { - type: 'hint', - code: 'boarding-ramp', - summary: 'vehicle-mounted boarding ramp available' - }, - ro: { - type: 'hint', - code: 'wheelchairs-space', - summary: 'space for wheelchairs' - }, - oa: { - type: 'hint', - code: 'wheelchairs-space-reservation', - summary: 'space for wheelchairs, subject to reservation' - }, - wv: { - type: 'hint', - code: 'wifi', - summary: 'WiFi available' - }, - wi: { - type: 'hint', - code: 'wifi', - summary: 'WiFi available' - }, - sn: { - type: 'hint', - code: 'snacks', - summary: 'snacks available for purchase' - }, - mb: { - type: 'hint', - code: 'snacks', - summary: 'snacks available for purchase' - }, - mp: { - type: 'hint', - code: 'snacks', - summary: 'snacks available for purchase at the seat' - }, - bf: { - type: 'hint', - code: 'barrier-free', - summary: 'barrier-free' - }, - rg: { - type: 'hint', - code: 'barrier-free-vehicle', - summary: 'barrier-free vehicle' - }, - bt: { - type: 'hint', - code: 'on-board-bistro', - summary: 'Bordbistro available' - }, - br: { - type: 'hint', - code: 'on-board-restaurant', - summary: 'Bordrestaurant available' - }, - ki: { - type: 'hint', - code: 'childrens-area', - summary: `children's area available` - }, - kk: { - type: 'hint', - code: 'parents-childrens-compartment', - summary: `parent-and-children compartment available` - }, - kr: { - type: 'hint', - code: 'kids-service', - summary: 'DB Kids Service available' - }, - ls: { - type: 'hint', - code: 'power-sockets', - summary: 'power sockets available' - }, - ev: { - type: 'hint', - code: 'replacement-service', - summary: 'replacement service' - }, - kl: { - type: 'hint', - code: 'air-conditioned', - summary: 'air-conditioned vehicle' - }, - r0: { - type: 'hint', - code: 'upward-escalator', - summary: 'upward escalator' - }, - au: { - type: 'hint', - code: 'elevator', - summary: 'elevator available' - }, - ck: { - type: 'hint', - code: 'komfort-checkin', - summary: 'Komfort-Checkin available' - }, - it: { - type: 'hint', - code: 'ice-sprinter', - summary: 'ICE Sprinter service' - }, - rp: { - type: 'hint', - code: 'compulsory-reservation', - summary: 'compulsory seat reservation' - }, - rm: { - type: 'hint', - code: 'optional-reservation', - summary: 'optional seat reservation' - }, - scl: { - type: 'hint', - code: 'all-2nd-class-seats-reserved', - summary: 'all 2nd class seats reserved' - }, - acl: { - type: 'hint', - code: 'all-seats-reserved', - summary: 'all seats reserved' - }, - sk: { - type: 'hint', - code: 'oversize-luggage-forbidden', - summary: 'oversize luggage not allowed' - }, - hu: { - type: 'hint', - code: 'animals-forbidden', - summary: 'animals not allowed, except guide dogs' - }, - ik: { - type: 'hint', - code: 'baby-cot-required', - summary: 'baby cot/child seat required' - }, - ee: { - type: 'hint', - code: 'on-board-entertainment', - summary: 'on-board entertainment available' - }, - toilet: { - type: 'hint', - code: 'toilet', - summary: 'toilet available' - }, - oc: { - type: 'hint', - code: 'wheelchair-accessible-toilet', - summary: 'wheelchair-accessible toilet available' - }, - iz: { - type: 'hint', - code: 'intercity-2', - summary: 'Intercity 2' - } -}) - const codesByIcon = Object.assign(Object.create(null), { cancel: 'cancelled' }) diff --git a/parse/journey-leg.js b/parse/journey-leg.js index 0107a85f..3c08cfc5 100644 --- a/parse/journey-leg.js +++ b/parse/journey-leg.js @@ -41,7 +41,6 @@ const applyRemarks = (leg, hints, warnings, refs) => { const createParseJourneyLeg = (profile, opt, data) => { const {locations, lines, hints, warnings, polylines} = data - // todo: pt.status // todo: pt.status, pt.isPartCncl // todo: pt.isRchbl, pt.chRatingRT, pt.chgDurR, pt.minChg // todo: pt.sDays