Simplify _findFirstBulk (#1521)
This commit is contained in:
parent
a00ed41838
commit
e1477adeec
@ -296,7 +296,7 @@ class DictionaryDatabase {
|
|||||||
|
|
||||||
findTagMetaBulk(items) {
|
findTagMetaBulk(items) {
|
||||||
const predicate = (row, item) => (row.dictionary === item.dictionary);
|
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) {
|
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) => {
|
return new Promise((resolve, reject) => {
|
||||||
const count = items.length;
|
const count = items.length;
|
||||||
const results = new Array(count);
|
const results = new Array(count);
|
||||||
@ -462,7 +462,7 @@ class DictionaryDatabase {
|
|||||||
const query = IDBKeyRange.only(item.query);
|
const query = IDBKeyRange.only(item.query);
|
||||||
|
|
||||||
const onFind = (row) => {
|
const onFind = (row) => {
|
||||||
results[itemIndex] = createResult(row, itemIndex);
|
results[itemIndex] = row;
|
||||||
if (++completeCount >= count) {
|
if (++completeCount >= count) {
|
||||||
resolve(results);
|
resolve(results);
|
||||||
}
|
}
|
||||||
@ -501,10 +501,6 @@ class DictionaryDatabase {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_createTagMeta(row, index) {
|
|
||||||
return {row, index};
|
|
||||||
}
|
|
||||||
|
|
||||||
_createTermMeta({expression, mode, data, dictionary}, index) {
|
_createTermMeta({expression, mode, data, dictionary}, index) {
|
||||||
return {expression, mode, data, dictionary, index};
|
return {expression, mode, data, dictionary, index};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user