4.0.1 • Published 1 year ago

hafas-collect-departures-at v4.0.1

Weekly downloads
15
License
ISC
Repository
github
Last release
1 year ago

hafas-collect-departures-at

Utility to collect departures, using any HAFAS client.

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

Installing

npm install hafas-collect-departures-at

Usage

const createHafas = require('vbb-hafas')
const createCollectDeps = require('hafas-collect-departures-at')

const fooStation = '900000100001'
const hafas = createHafas('my-awesome-program')
const collectDeps = createCollectDeps(hafas.departures, {
	remarks: true, products: {tram: false}
})
const depsAtFoo = collectDeps(fooStation, Date.now())

const fetchDepsTwice = async () => {
	let iterations = 0
	for await (const deps of depsAtFoo) {
		if (++iterations > 2) break
		console.log(deps)
	}
}

fetchDepsTwice()
.catch(console.error)

while helper

If you don't like to use the async iteration syntax, there's a helper that works like a regular while loop:

const createCollectWhile = require('hafas-collect-departures-at/while')

const shouldPick = (dep, i) => i < 10

const collectWhile = createCollectWhile(vbb.departures)
collectWhile(fooStation, Date.now(), shouldPick)
.then(console.log)
.catch(console.error)

collectWhile() returns a Promise that will resolve with an array of 10 items.

Related

Contributing

If you have a question or have difficulties using hafas-collect-departures-at, 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.

3.1.3

1 year ago

3.1.2

1 year ago

4.0.1

1 year ago

4.0.0

1 year ago

3.1.1

4 years ago

3.1.0

4 years ago

3.0.0

4 years ago

2.0.0

5 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.3.1

6 years ago

0.2.2

6 years ago

0.2.2-alpha.2

6 years ago

0.2.2-alpha.1

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago