nearby: return at most opt.results results

This commit is contained in:
Jannis R 2020-06-10 15:00:49 +02:00
parent ee94c651dd
commit a8a9303e6f
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5

View file

@ -353,7 +353,8 @@ const createClient = (profile, userAgent, opt = {}) => {
if (!Array.isArray(res.locL)) return [] if (!Array.isArray(res.locL)) return []
const ctx = {profile, opt, common, res} const ctx = {profile, opt, common, res}
return res.locL.map(loc => profile.parseNearby(ctx, loc)) const results = res.locL.map(loc => profile.parseNearby(ctx, loc))
return Number.isInteger(opt.results) ? results.slice(0, opt.results) : results
}) })
} }