Last active
August 29, 2015 14:21
-
-
Save lhahne/d8c0c24b84e16772ffca to your computer and use it in GitHub Desktop.
StationMetadataStore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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