fetch-commute-from-hafas

2.0.0 • Public • Published

fetch-commute-from-hafas

For a set commuting instructions, fetch journeys from HAFAS.

npm version build status ISC-licensed support me via GitHub Sponsors chat with me on Twitter

Installation

npm install fetch-commute-from-hafas

Usage

const createHafas = require('bvg-hafas')
const fetchJourneysForCommute = require('fetch-commute-from-hafas')

const commute = {
	title: 'Seestr. to Potsdamer Platz via Friedrichstr.',
	from: {
		stop: '900000009103', // U Seestr.
		bufferBefore: 6 * 60 * 1000 // 6 minutes
	},
	transfers: [{
		stop: '900000100001', // S+U Friedrichstr.
		buffer: 30 * 1000 // 30 seconds
	}],
	to: {
		stop: '900000100020', // S+U Potsdamer Platz
		bufferAfter: 2 * 60 * 1000 // 2 minutes
	},
	products: {bus: false}
}
const when = new Date('2019-02-18T10:00:00+01:00')

const hafas = createHafas('render-berlin-commute example')
fetchJourneysForCommute(hafas, commute, when)
.then((results) => {
	for (const res of results) {
		if (!res.err) console.log(res.journey)
	}
})
.catch(console.error)

Related

Contributing

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

Dependencies (2)

Dev Dependencies (4)

Package Sidebar

Install

npm i fetch-commute-from-hafas

Weekly Downloads

0

Version

2.0.0

License

ISC

Unpacked Size

7.86 kB

Total Files

5

Last publish

Collaborators

  • derhuerst