Skip to content

Instantly share code, notes, and snippets.

@lhahne
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lhahne/d8c0c24b84e16772ffca to your computer and use it in GitHub Desktop.
Save lhahne/d8c0c24b84e16772ffca to your computer and use it in GitHub Desktop.
StationMetadataStore
var Bacon = require('bacon')
var _ = require('lodash')
var METADATA_URL = 'http://rata.digitraffic.fi/api/v1/metadata/station'
var stations = Bacon.fromPromise(fetch(METADATA_URL))
.flatMap(response => Bacon.fromPromise(response.json()))
var stationsByCode = stations.map((stations) =>
_.indexBy(stations, 'stationShortCode'))
module.exports = {
stations: stations,
stationsByCode: stationsByCode
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment