rename stringify -> format

This commit is contained in:
Jannis R 2017-11-12 00:53:34 +01:00
parent e6982753cd
commit 5b96c89b5b
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
14 changed files with 52 additions and 52 deletions

17
format/address.js Normal file
View file

@ -0,0 +1,17 @@
'use strict'
const formatCoord = require('./coord')
const formatAddress = (latitude, longitude, name) => {
if (!latitude || !longitude || !name) throw new Error('invalid address.')
return {
type: 'A',
name,
crd: {
x: formatCoord(longitude),
y: formatCoord(latitude)
}
}
}
module.exports = formatAddress

5
format/coord.js Normal file
View file

@ -0,0 +1,5 @@
'use strict'
const formatCoord = x => Math.round(x * 1000000)
module.exports = formatCoord

View file

@ -2,8 +2,8 @@
const moment = require('moment-timezone')
const stringifyDate = (tz, when) => {
const formatDate = (tz, when) => {
moment(when).tz(tz).format('YYYYMMDD')
}
module.exports = stringifyDate
module.exports = formatDate

View file

@ -1,8 +1,8 @@
'use strict'
const stringifyLocationFilter = (stations, addresses, poi) => {
const formatLocationFilter = (stations, addresses, poi) => {
if (stations && addresses && poi) return 'ALL'
return (stations ? 'S' : '') + (addresses ? 'A' : '') + (poi ? 'P' : '')
}
module.exports = stringifyLocationFilter
module.exports = formatLocationFilter

18
format/poi.js Normal file
View file

@ -0,0 +1,18 @@
'use strict'
const formatCoord = require('./coord')
const formatPoi = (latitude, longitude, id, name) => {
if (!latitude || !longitude || !id || !name) throw new Error('invalid poi.')
return {
type: 'P',
name,
lid: 'L=' + id,
crd: {
x: formatCoord(longitude),
y: formatCoord(latitude)
}
}
}
module.exports = formatPoi

5
format/station.js Normal file
View file

@ -0,0 +1,5 @@
'use strict'
const formatStation = id => ({type: 'S', lid: 'L=' + id})
module.exports = formatStation

View file

@ -2,8 +2,8 @@
const moment = require('moment-timezone')
const stringifyTime = (tz, when) => {
const formatTime = (tz, when) => {
return moment(when).tz(tz).format('HHmmss')
}
module.exports = stringifyTime
module.exports = formatTime

View file

@ -7,7 +7,7 @@
"index.js",
"lib",
"parse",
"stringify"
"format"
],
"author": "Jannis R <mail@jannisr.de>",
"homepage": "https://github.com/derhuerst/hafas-client",

View file

@ -1,17 +0,0 @@
'use strict'
const stringifyCoord = require('./coord')
const stringifyAddress = (latitude, longitude, name) => {
if (!latitude || !longitude || !name) throw new Error('invalid address.')
return {
type: 'A',
name,
crd: {
x: stringifyCoord(longitude),
y: stringifyCoord(latitude)
}
}
}
module.exports = stringifyAddress

View file

@ -1,5 +0,0 @@
'use strict'
const stringifyCoord = x => Math.round(x * 1000000)
module.exports = stringifyCoord

View file

@ -1,18 +0,0 @@
'use strict'
const stringifyCoord = require('./coord')
const stringifyPoi = (latitude, longitude, id, name) => {
if (!latitude || !longitude || !id || !name) throw new Error('invalid poi.')
return {
type: 'P',
name,
lid: 'L=' + id,
crd: {
x: stringifyCoord(longitude),
y: stringifyCoord(latitude)
}
}
}
module.exports = stringifyPoi

View file

@ -1,5 +0,0 @@
'use strict'
const stringifyStation = id => ({type: 'S', lid: 'L=' + id})
module.exports = stringifyStation