2.0.0 • Published 7 years ago
discover-db-stations v2.0.0
discover-db-stations
Discover Deutsche Bahn stations by querying departures. It tries to find all stations that all trains known by Deutsche Bahn stop at. Analogous to discover-vbb-stations.
Installing
npm install discover-db-stationsUsage
using the command line
Using npx:
npx discover-db-stations <station-id> >stations.ndjsonusing JavaScript
const walk = require('discover-db-stations')
walk(stationId) // where to start
.on('data', console.log)
.on('error', console.error)walk() returns a readable stream in object mode. It emits the following events:
data: a new station that has been discoveredstats: an object with the following keys: -stations: the number of stations discovered -requests: the number of requests sent -queued: the number of queued station IDsedge: a connection between two stations, with the following keys: -source: a Friendly Public Transport Format1.2.0stationobject -target: a Friendly Public Transport Format1.2.0stationobject -duration: time to travel, in milliseconds -line: an db-hafaslineobject
API
walk(stationId, [opt])stationId must be a string and a valid IBNR.
opt may have the following keys. It will be passed into queue().
concurrency: number of requests run in parallel – default:2timeout: timeout for a single job in milliseconds – default:10000
Contributing
If you have a question, found a bug or want to propose a feature, have a look at the issues page.