aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/translator.js32
1 files changed, 14 insertions, 18 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index e5e34ed8..ebb02687 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -424,13 +424,13 @@ class Translator {
definition.frequencies = [];
}
- for (const meta of await this.database.findKanjiMetaBulk(kanjiList2, titles)) {
- if (meta.mode !== 'freq') { continue; }
- definitions[meta.index].frequencies.push({
- character: meta.character,
- frequency: meta.data,
- dictionary: meta.dictionary
- });
+ const metas = await this.database.findKanjiMetaBulk(kanjiList2, titles);
+ for (const {character, mode, data, dictionary, index} of metas) {
+ switch (mode) {
+ case 'freq':
+ definitions[index].frequencies.push({character, frequency: data, dictionary});
+ break;
+ }
}
return definitions;
@@ -471,17 +471,13 @@ class Translator {
}
const metas = await this.database.findTermMetaBulk(expressionsUnique, titles);
- for (const meta of metas) {
- if (meta.mode !== 'freq') {
- continue;
- }
-
- for (const term of termsUnique[meta.index]) {
- term.frequencies.push({
- expression: meta.expression,
- frequency: meta.data,
- dictionary: meta.dictionary
- });
+ for (const {expression, mode, data, dictionary, index} of metas) {
+ switch (mode) {
+ case 'freq':
+ for (const term of termsUnique[index]) {
+ term.frequencies.push({expression, frequency: data, dictionary});
+ }
+ break;
}
}
}