2017-11-12 19:15:13 +01:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const formatLocation = (profile, l) => {
|
|
|
|
if ('string' === typeof l) return profile.formatStation(l)
|
2017-12-12 23:40:12 +01:00
|
|
|
if ('object' === typeof l && !Array.isArray(l)) {
|
2017-11-12 19:15:13 +01:00
|
|
|
if (l.type === 'station') return profile.formatStation(l.id)
|
2017-12-12 23:40:12 +01:00
|
|
|
if ('string' === typeof l.id) return profile.formatPoi(l)
|
|
|
|
if ('string' === typeof l.address) return profile.formatAddress(l)
|
2017-11-12 19:15:13 +01:00
|
|
|
throw new Error('invalid location type: ' + l.type)
|
|
|
|
}
|
|
|
|
throw new Error('valid station, address or poi required.')
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = formatLocation
|