hafas-departures-in-direction
Pass in a hafas-client
-compatible HAFAS API client and get departures at a station in a certain direction.
Note: This library is obsolete because hafas-client
now supports querying departures by direction. Use it directly or hafas-collect-departures-at
to collect departures with any termination logic.
Installing
npm install hafas-departures-in-direction
Usage
Pass in your hafas-client
-compatible HAFAS API client. In this case, we're going to use vbb-hafas
:
const setup = const hafas = const depsInDirection =
Specify the direction as the next station after the one you're querying departures for. depsInDirection
will then query departures, advancing in time until it found enough results or sent enough requests.
const friedrichstr = '900000100001' // where to get departuresconst brandenburgerTor = '900000100025' // direction
The results will look similar to those of hafas-client
.
API
depsInDirection =
fetchDepartures(stationId, opt)
should be API-compatible with hafas-client.departures
. fetchJourneyLeg(ref, lineName, opt)
should be API-compatible with hafas-client.journeyLeg
. Both should return valid FPTF 1.1.1
.
opt
overrides the following defaults:
concurrency: 4 // max nr. of parallel requests results: 10 // nr. of results to collect maxQueries: 10 // max nr. of requests when: null // time in ms since epoch
Returns a Promise
that resolves with an array of departures.