db-vendo-client/format/address.js

20 lines
361 B
JavaScript
Raw Normal View History

2017-11-12 00:53:34 +01:00
'use strict'
const formatCoord = require('./coord')
const formatAddress = (a) => {
// todo: type-checking, better error msgs
if (!a.latitude || !a.longitude || !a.name) throw new Error('invalid address.')
2017-11-12 00:53:34 +01:00
return {
type: 'A',
name: a.name,
2017-11-12 00:53:34 +01:00
crd: {
x: formatCoord(a.longitude),
y: formatCoord(a.latitude)
2017-11-12 00:53:34 +01:00
}
}
}
module.exports = formatAddress