Skip to content

Commit

Permalink
implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Aug 9, 2018
1 parent 747bba1 commit 95896ef
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
32 changes: 31 additions & 1 deletion example.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
'use strict'

// todo
const createHafas = require('.')

const jungfernheide = '900000020201'
const tempelhof = '900000068201'

const hafas = createHafas('bvg-hafas example')

hafas.journeys(jungfernheide, tempelhof, {results: 1})
// .then(([journey]) => {
// const leg = journey.legs[0]
// return hafas.journeyLeg(leg.id, leg.line.name)
// })

// hafas.departures(jungfernheide, { duration: 5 })
// hafas.locations('friedrichstr', {results: 2})
// hafas.locations('mauerpark', {results: 2})
// hafas.location(jungfernheide)
// hafas.nearby({
// type: 'location',
// latitude: 52.5137344,
// longitude: 13.4744798
// }, {distance: 200})
// hafas.radar({
// north: 52.52411,
// west: 13.41002,
// south: 52.51942,
// east: 13.41709
// }, {results: 10})

.then(console.log)
.catch(console.error)
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
'use strict'

// todo
const createHafasClient = require('hafas-client')
const bvgProfile = require('hafas-client/p/bvg')

const createClient = (userAgent) => {
return createHafasClient(bvgProfile, userAgent)
}

module.exports = createClient
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
"node": ">=6"
},
"dependencies": {
"hafas-client": "^3.0.0-alpha.21"
}
}
9 changes: 8 additions & 1 deletion throttle.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
'use strict'

// todo
const createThrottledClient = require('hafas-client/throttle')
const bvgProfile = require('hafas-client/p/bvg')

const throttle = (limit = 5, interval = 1000) => {
return createThrottledClient(bvgProfile, limit, interval)
}

module.exports = throttle

0 comments on commit 95896ef

Please sign in to comment.