Skip to content
Use any HAFAS API to monitor journeys from A to B.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig
.gitignore
.travis.yml
example.js
index.js
license.md
package.json
readme.md
test.js
to-file.js

readme.md

hafas-monitor-journeys

Use any HAFAS API to monitor journeys from A to B.

npm version build status ISC-licensed chat on gitter support me on Patreon

Installing

npm install hafas-monitor-journeys

Usage

const createHafas = require('vbb-hafas')
const monitor = require('hafas-monitor-journeys')

const leinestr = '900000079201'
const schönleinstr = '900000016201'

const tasks = [{
	from: leinestr,
	to: schönleinstr,
	when: t => t, // query for the current point in time
}, {
	from: leinestr,
	to: schönleinstr,
	when: t => t + 10 * 60 * 1000 // query 10 minutes ahead
}]

const onJobDone = (err, journeys, job, iteration) => {
	if (err) return console.error(err)

	const ahead = Math.round((job.when - job.started) / 1000)
	console.log(
		'iteration ' + iteration,
		ahead + 's ahead',
		journeys.length + ' journeys'
	)
}

const onEnd = (iteration) => {
	console.log('iteration ' + iteration + ' done')
}

const hafas = createHafas('my-awesome-program')
const run = monitor(hafas.journeys, tasks)
run(onJobDone, onEnd)
iteration 1 0s ahead 5 journeys
iteration 1 600s ahead 5 journeys
iteration 1 done

Contributing

If you have a question or have difficulties using hafas-monitor-journeys, 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.

You can’t perform that action at this time.