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

Commit

Permalink
Simplify _findFirstBulk (#1521)
Browse files Browse the repository at this point in the history
  • Loading branch information
toasted-nutbread authored Mar 13, 2021
1 parent a00ed41 commit e1477ad
Showing 1 changed file with 3 additions and 7 deletions.
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

0 comments on commit e1477ad

Please sign in to comment.