From f97877a2097c8b27b75099e489b93db255cb68be Mon Sep 17 00:00:00 2001 From: siikamiika Date: Mon, 11 Nov 2019 02:28:00 +0200 Subject: promise improvements --- ext/bg/js/mecab.js | 6 ++---- ext/bg/js/search-query-parser.js | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ext/bg/js/mecab.js b/ext/bg/js/mecab.js index 4c62c2b0..b9f2d0b3 100644 --- a/ext/bg/js/mecab.js +++ b/ext/bg/js/mecab.js @@ -58,12 +58,10 @@ class Mecab { const sequence = this.sequence++; this.listeners[sequence] = { - callback: (data) => { - resolve(data); - }, + callback: resolve, timer: setTimeout(() => { delete this.listeners[sequence]; - reject(`Mecab invoke timed out in ${Mecab.timeout} ms`); + reject(new Error(`Mecab invoke timed out in ${Mecab.timeout} ms`)); }, Mecab.timeout) } diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index f8e53963..2aee45dd 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -97,8 +97,8 @@ class QueryParser { } } - const contents = await Promise.all(Object.values(results).map(async result => { - return await apiTemplateRender('query-parser.html', { + const contents = await Promise.all(Object.values(results).map(result => { + return apiTemplateRender('query-parser.html', { terms: result.map((term) => { return term.filter(part => part.text.trim()).map((part) => { return { -- cgit v1.2.3