Home

Awesome

hafas-discover-stations

Pass in a HAFAS client, discover stops/stations by querying departures. It tries to find all stops/stations that all trains known by the endpoint stop at.

npm version ISC-licensed minimum Node.js version support me via GitHub Sponsors chat with me on Twitter

Installing

npm install hafas-discover-stations

Usage

import {createWalkAndDiscoverStations as createWalk} from 'hafas-discover-stations'
import {createClient as createHafas} from 'hafas-client'
import {profile as dbProfile} from 'hafas-client/p/db/index.js'

const hafas = createHafas(dbProfile, 'my-awesome-program')
const walk = createWalk(hafas)

const berlinFriedrichstr = '8011306' // where to start
for await (const stopOrStation of walk(berlinFriedrichstr)) {
	console.log(stopOrStation)
}

walk() returns a readable stream in object mode. It emits the following events:

API

walk(stationId, [opt])

opt may have the following keys. It will be passed into queue().

Contributing

If you have a question or need support using hafas-discover-stations, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, use the issues page.