promise improvements

This commit is contained in:
siikamiika 2019-11-11 02:28:00 +02:00
parent b336ab3a9a
commit f97877a209
2 changed files with 4 additions and 6 deletions

View File

@ -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)
}

View File

@ -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 {