journeys: fix opt.results === null 🐛

This commit is contained in:
Jannis R 2019-03-01 11:37:25 +01:00
parent 16f98b943e
commit 29aea9a5ef
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5

View file

@ -232,18 +232,15 @@ const createClient = (profile, userAgent, request = _request) => {
j = parse(j) j = parse(j)
journeys.push(j) journeys.push(j)
if (journeys.length >= opt.results) { // collected enough if (opt.results !== null && journeys.length >= opt.results) { // collected enough
laterRef = d.outCtxScrF laterRef = d.outCtxScrF
return { return {earlierRef, laterRef, journeys}
earlierRef,
laterRef,
journeys
}
} }
const dep = +new Date(j.legs[0].departure) const dep = +new Date(j.legs[0].departure)
if (dep > latestDep) latestDep = dep if (dep > latestDep) latestDep = dep
} }
if (opt.results === null) return {earlierRef, laterRef, journeys}
const when = new Date(latestDep) const when = new Date(latestDep)
return more(when, d.outCtxScrF) // otherwise continue return more(when, d.outCtxScrF) // otherwise continue
}) })