How to use the hafas-client/parse.journey function in hafas-client

To help you get started, we’ve selected a few hafas-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github derhuerst / vbb-hafas / lib / parse.js View on Github external
const journey = (l, p, r) => {
	const parseJourney = parse.journey('Europe/Berlin', l, p, r)

	const parseJourneyWithTickets = (j) => {
		const journey = parseJourney(j)

		if (
			j.trfRes &&
			Array.isArray(j.trfRes.fareSetL) &&
			j.trfRes.fareSetL[0] &&
			Array.isArray(j.trfRes.fareSetL[0].fareL)
		) {
			journey.tickets = []
			const sets = j.trfRes.fareSetL[0].fareL
			for (let s of sets) {
				if (!Array.isArray(s.ticketL) || s.ticketL.length === 0) continue
				for (let t of s.ticketL) {
					const ticket = parseTicket(t)