promise improvements
This commit is contained in:
parent
b336ab3a9a
commit
f97877a209
@ -58,12 +58,10 @@ class Mecab {
|
|||||||
const sequence = this.sequence++;
|
const sequence = this.sequence++;
|
||||||
|
|
||||||
this.listeners[sequence] = {
|
this.listeners[sequence] = {
|
||||||
callback: (data) => {
|
callback: resolve,
|
||||||
resolve(data);
|
|
||||||
},
|
|
||||||
timer: setTimeout(() => {
|
timer: setTimeout(() => {
|
||||||
delete this.listeners[sequence];
|
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)
|
}, Mecab.timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,8 +97,8 @@ class QueryParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const contents = await Promise.all(Object.values(results).map(async result => {
|
const contents = await Promise.all(Object.values(results).map(result => {
|
||||||
return await apiTemplateRender('query-parser.html', {
|
return apiTemplateRender('query-parser.html', {
|
||||||
terms: result.map((term) => {
|
terms: result.map((term) => {
|
||||||
return term.filter(part => part.text.trim()).map((part) => {
|
return term.filter(part => part.text.trim()).map((part) => {
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user