From 7093d8f06e26daf825745be26238d92ed122e60b Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 4 Nov 2019 20:14:51 -0500 Subject: Simplify how definition count is limited --- ext/bg/js/api.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js index f379e65a..c50db76f 100644 --- a/ext/bg/js/api.js +++ b/ext/bg/js/api.js @@ -75,16 +75,15 @@ async function apiOptionsSave(source) { async function apiTermsFind(text, optionsContext) { const options = await apiOptionsGet(optionsContext); const [definitions, length] = await utilBackend().translator.findTerms(text, options); - return { - length, - definitions: definitions.slice(0, options.general.maxResults) - }; + definitions.splice(options.general.maxResults); + return {length, definitions}; } async function apiKanjiFind(text, optionsContext) { const options = await apiOptionsGet(optionsContext); const definitions = await utilBackend().translator.findKanji(text, options); - return definitions.slice(0, options.general.maxResults); + definitions.splice(options.general.maxResults); + return definitions; } async function apiDefinitionAdd(definition, mode, context, optionsContext) { -- cgit v1.2.3