mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
nearby: return at most opt.results results
This commit is contained in:
parent
ee94c651dd
commit
a8a9303e6f
1 changed files with 2 additions and 1 deletions
3
index.js
3
index.js
|
@ -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
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue