readableFrom: make maxDuration optional

[ci skip]
This commit is contained in:
Jannis R 2018-11-01 19:38:29 +01:00
parent 02e0e513ef
commit 9d96902794
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
2 changed files with 3 additions and 3 deletions

View file

@ -12,7 +12,7 @@ With `opt`, you can override the default options, which look like this:
{ {
when: new Date(), when: new Date(),
maxTransfers: 5, // maximum of 5 transfers maxTransfers: 5, // maximum of 5 transfers
maxDuration: 20, // maximum travel duration in minutes maxDuration: 20, // maximum travel duration in minutes, pass `null` for infinite
products: { products: {
// These entries may vary from profile to profile! // These entries may vary from profile to profile!
suburban: true, suburban: true,

View file

@ -470,7 +470,7 @@ const createClient = (profile, userAgent, request = _request) => {
opt = Object.assign({ opt = Object.assign({
when: Date.now(), when: Date.now(),
maxTransfers: 5, // maximum of 5 transfers maxTransfers: 5, // maximum of 5 transfers
maxDuration: 20, // maximum travel duration in minutes maxDuration: 20, // maximum travel duration in minutes, pass `null` for infinite
products: {} products: {}
}, opt) }, opt)
if (Number.isNaN(+opt.when)) throw new Error('opt.when is invalid') if (Number.isNaN(+opt.when)) throw new Error('opt.when is invalid')
@ -480,7 +480,7 @@ const createClient = (profile, userAgent, request = _request) => {
meth: 'LocGeoReach', meth: 'LocGeoReach',
req: { req: {
loc: profile.formatLocation(profile, address, 'address'), loc: profile.formatLocation(profile, address, 'address'),
maxDur: opt.maxDuration, maxDur: opt.maxDuration === null ? -1 : opt.maxDuration,
maxChg: opt.maxTransfers, maxChg: opt.maxTransfers,
date: profile.formatDate(profile, opt.when), date: profile.formatDate(profile, opt.when),
time: profile.formatTime(profile, opt.when), time: profile.formatTime(profile, opt.when),