Simplify _findFirstBulk (#1521)

This commit is contained in:
toasted-nutbread 2021-03-13 11:42:04 -05:00 committed by GitHub
parent a00ed41838
commit e1477adeec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {
@ -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);
@ -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);
}
@ -501,10 +501,6 @@ class DictionaryDatabase {
};
}
_createTagMeta(row, index) {
return {row, index};
}
_createTermMeta({expression, mode, data, dictionary}, index) {
return {expression, mode, data, dictionary, index};
}