mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
minor refactoring
This commit is contained in:
parent
0a9042aa83
commit
d8c9fd7a33
1 changed files with 4 additions and 3 deletions
7
index.js
7
index.js
|
@ -8,6 +8,7 @@ const defaultProfile = require('./lib/default-profile')
|
||||||
const _request = require('./lib/request')
|
const _request = require('./lib/request')
|
||||||
|
|
||||||
const isObj = o => o !== null && 'object' === typeof o && !Array.isArray(o)
|
const isObj = o => o !== null && 'object' === typeof o && !Array.isArray(o)
|
||||||
|
const isNonEmptyString = str => 'string' === typeof str && str.length > 0
|
||||||
|
|
||||||
const createClient = (profile, request = _request) => {
|
const createClient = (profile, request = _request) => {
|
||||||
profile = Object.assign({}, defaultProfile, profile)
|
profile = Object.assign({}, defaultProfile, profile)
|
||||||
|
@ -110,7 +111,7 @@ const createClient = (profile, request = _request) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const locations = (query, opt = {}) => {
|
const locations = (query, opt = {}) => {
|
||||||
if ('string' !== typeof query || !query) {
|
if (!isNonEmptyString(query)) {
|
||||||
throw new Error('query must be a non-empty string.')
|
throw new Error('query must be a non-empty string.')
|
||||||
}
|
}
|
||||||
opt = Object.assign({
|
opt = Object.assign({
|
||||||
|
@ -204,10 +205,10 @@ const createClient = (profile, request = _request) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const journeyLeg = (ref, lineName, opt = {}) => {
|
const journeyLeg = (ref, lineName, opt = {}) => {
|
||||||
if ('string' !== typeof ref || !ref) {
|
if (!isNonEmptyString(ref)) {
|
||||||
throw new Error('ref must be a non-empty string.')
|
throw new Error('ref must be a non-empty string.')
|
||||||
}
|
}
|
||||||
if ('string' !== typeof lineName || !lineName) {
|
if (!isNonEmptyString(lineName)) {
|
||||||
throw new Error('lineName must be a non-empty string.')
|
throw new Error('lineName must be a non-empty string.')
|
||||||
}
|
}
|
||||||
opt = Object.assign({
|
opt = Object.assign({
|
||||||
|
|
Loading…
Add table
Reference in a new issue