Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Simplify _findFirstBulk #1521

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions ext/js/language/dictionary-database.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class DictionaryDatabase {

findTagMetaBulk(items) {
const predicate = (row, item) => (row.dictionary === item.dictionary);
return this._findFirstBulk('tagMeta', 'name', items, predicate, this._createTagMeta.bind(this));
return this._findFirstBulk('tagMeta', 'name', items, predicate);
}

findTagForTitle(name, title) {
Expand Down Expand Up @@ -442,7 +442,7 @@ class DictionaryDatabase {
});
}

_findFirstBulk(objectStoreName, indexName, items, predicate, createResult) {
_findFirstBulk(objectStoreName, indexName, items, predicate) {
return new Promise((resolve, reject) => {
const count = items.length;
const results = new Array(count);
Expand All @@ -462,7 +462,7 @@ class DictionaryDatabase {
const query = IDBKeyRange.only(item.query);

const onFind = (row) => {
results[itemIndex] = createResult(row, itemIndex);
results[itemIndex] = row;
if (++completeCount >= count) {
resolve(results);
}
Expand Down Expand Up @@ -501,10 +501,6 @@ class DictionaryDatabase {
};
}

_createTagMeta(row, index) {
return {row, index};
}

_createTermMeta({expression, mode, data, dictionary}, index) {
return {expression, mode, data, dictionary, index};
}
Expand Down