From 5b96c89b5b3998c2052b358d0502f4df5b8516b9 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Sun, 12 Nov 2017 00:53:34 +0100 Subject: [PATCH] rename stringify -> format --- format/address.js | 17 +++++++++++++++++ format/coord.js | 5 +++++ {stringify => format}/date.js | 4 ++-- {stringify => format}/filters.js | 0 {stringify => format}/index.js | 0 {stringify => format}/location-filter.js | 4 ++-- format/poi.js | 18 ++++++++++++++++++ format/station.js | 5 +++++ {stringify => format}/time.js | 4 ++-- package.json | 2 +- stringify/address.js | 17 ----------------- stringify/coord.js | 5 ----- stringify/poi.js | 18 ------------------ stringify/station.js | 5 ----- 14 files changed, 52 insertions(+), 52 deletions(-) create mode 100644 format/address.js create mode 100644 format/coord.js rename {stringify => format}/date.js (59%) rename {stringify => format}/filters.js (100%) rename {stringify => format}/index.js (100%) rename {stringify => format}/location-filter.js (56%) create mode 100644 format/poi.js create mode 100644 format/station.js rename {stringify => format}/time.js (60%) delete mode 100644 stringify/address.js delete mode 100644 stringify/coord.js delete mode 100644 stringify/poi.js delete mode 100644 stringify/station.js diff --git a/format/address.js b/format/address.js new file mode 100644 index 00000000..62ebe39f --- /dev/null +++ b/format/address.js @@ -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 diff --git a/format/coord.js b/format/coord.js new file mode 100644 index 00000000..7d1ff695 --- /dev/null +++ b/format/coord.js @@ -0,0 +1,5 @@ +'use strict' + +const formatCoord = x => Math.round(x * 1000000) + +module.exports = formatCoord diff --git a/stringify/date.js b/format/date.js similarity index 59% rename from stringify/date.js rename to format/date.js index 0649e487..f3c7947b 100644 --- a/stringify/date.js +++ b/format/date.js @@ -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 diff --git a/stringify/filters.js b/format/filters.js similarity index 100% rename from stringify/filters.js rename to format/filters.js diff --git a/stringify/index.js b/format/index.js similarity index 100% rename from stringify/index.js rename to format/index.js diff --git a/stringify/location-filter.js b/format/location-filter.js similarity index 56% rename from stringify/location-filter.js rename to format/location-filter.js index a147b14b..79a79706 100644 --- a/stringify/location-filter.js +++ b/format/location-filter.js @@ -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 diff --git a/format/poi.js b/format/poi.js new file mode 100644 index 00000000..4af29ea9 --- /dev/null +++ b/format/poi.js @@ -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 diff --git a/format/station.js b/format/station.js new file mode 100644 index 00000000..418e5181 --- /dev/null +++ b/format/station.js @@ -0,0 +1,5 @@ +'use strict' + +const formatStation = id => ({type: 'S', lid: 'L=' + id}) + +module.exports = formatStation diff --git a/stringify/time.js b/format/time.js similarity index 60% rename from stringify/time.js rename to format/time.js index a50e4f29..8d25907f 100644 --- a/stringify/time.js +++ b/format/time.js @@ -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 diff --git a/package.json b/package.json index 01e7ae0d..7b55ba5e 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "index.js", "lib", "parse", - "stringify" + "format" ], "author": "Jannis R ", "homepage": "https://github.com/derhuerst/hafas-client", diff --git a/stringify/address.js b/stringify/address.js deleted file mode 100644 index 19edd8e9..00000000 --- a/stringify/address.js +++ /dev/null @@ -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 diff --git a/stringify/coord.js b/stringify/coord.js deleted file mode 100644 index 67a4d9cb..00000000 --- a/stringify/coord.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict' - -const stringifyCoord = x => Math.round(x * 1000000) - -module.exports = stringifyCoord diff --git a/stringify/poi.js b/stringify/poi.js deleted file mode 100644 index f0d9cb32..00000000 --- a/stringify/poi.js +++ /dev/null @@ -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 diff --git a/stringify/station.js b/stringify/station.js deleted file mode 100644 index 09d916e1..00000000 --- a/stringify/station.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict' - -const stringifyStation = id => ({type: 'S', lid: 'L=' + id}) - -module.exports = stringifyStation