From a8a9303e6f03fca289daafbc6d749f4860c5081d Mon Sep 17 00:00:00 2001 From: Jannis R Date: Wed, 10 Jun 2020 15:00:49 +0200 Subject: [PATCH] nearby: return at most opt.results results --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ab0ae1e7..19d689db 100644 --- a/index.js +++ b/index.js @@ -353,7 +353,8 @@ const createClient = (profile, userAgent, opt = {}) => { if (!Array.isArray(res.locL)) return [] 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 }) }