summaryrefslogtreecommitdiff
path: root/ext/bg/js/database.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-22 14:50:21 -0500
committerGitHub <noreply@github.com>2020-02-22 14:50:21 -0500
commitf8f03f3af0ab031cc58bf5ad3f782c8d45137430 (patch)
tree3116b3a9429077d77f16d374835ab768d8b0d9d4 /ext/bg/js/database.js
parentf3c4b0e1e14cbdfb86c692e89144c762801b2339 (diff)
parent418e7f9968ba8a6e302ec1e1b6d7dafe4b85fd97 (diff)
Merge pull request #362 from toasted-nutbread/more-type-refactoring
More type refactoring
Diffstat (limited to 'ext/bg/js/database.js')
-rw-r--r--ext/bg/js/database.js28
1 files changed, 14 insertions, 14 deletions
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index 453cf15f..1f6810cf 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -149,15 +149,15 @@ class Database {
await Promise.all(promises);
}
- async findTermsBulk(termList, titles, wildcard) {
+ async findTermsBulk(termList, dictionaries, wildcard) {
this._validate();
const promises = [];
- const visited = {};
+ const visited = new Set();
const results = [];
const processRow = (row, index) => {
- if (titles.includes(row.dictionary) && !hasOwn(visited, row.id)) {
- visited[row.id] = true;
+ if (dictionaries.has(row.dictionary) && !visited.has(row.id)) {
+ visited.add(row.id);
results.push(Database._createTerm(row, index));
}
};
@@ -184,13 +184,13 @@ class Database {
return results;
}
- async findTermsExactBulk(termList, readingList, titles) {
+ async findTermsExactBulk(termList, readingList, dictionaries) {
this._validate();
const promises = [];
const results = [];
const processRow = (row, index) => {
- if (row.reading === readingList[index] && titles.includes(row.dictionary)) {
+ if (row.reading === readingList[index] && dictionaries.has(row.dictionary)) {
results.push(Database._createTerm(row, index));
}
};
@@ -234,16 +234,16 @@ class Database {
return results;
}
- async findTermMetaBulk(termList, titles) {
- return this._findGenericBulk('termMeta', 'expression', termList, titles, Database._createTermMeta);
+ async findTermMetaBulk(termList, dictionaries) {
+ return this._findGenericBulk('termMeta', 'expression', termList, dictionaries, Database._createTermMeta);
}
- async findKanjiBulk(kanjiList, titles) {
- return this._findGenericBulk('kanji', 'character', kanjiList, titles, Database._createKanji);
+ async findKanjiBulk(kanjiList, dictionaries) {
+ return this._findGenericBulk('kanji', 'character', kanjiList, dictionaries, Database._createKanji);
}
- async findKanjiMetaBulk(kanjiList, titles) {
- return this._findGenericBulk('kanjiMeta', 'character', kanjiList, titles, Database._createKanjiMeta);
+ async findKanjiMetaBulk(kanjiList, dictionaries) {
+ return this._findGenericBulk('kanjiMeta', 'character', kanjiList, dictionaries, Database._createKanjiMeta);
}
async findTagForTitle(name, title) {
@@ -572,13 +572,13 @@ class Database {
return count > 0;
}
- async _findGenericBulk(tableName, indexName, indexValueList, titles, createResult) {
+ async _findGenericBulk(tableName, indexName, indexValueList, dictionaries, createResult) {
this._validate();
const promises = [];
const results = [];
const processRow = (row, index) => {
- if (titles.includes(row.dictionary)) {
+ if (dictionaries.has(row.dictionary)) {
results.push(createResult(row, index));
}
};