mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-07-03 11:02:31 +00:00
Use reduce() instead of forEach() for building KeyValueIndex
This commit is contained in:
parent
3c4fc90819
commit
d823ab4d2b
@ -10,9 +10,7 @@ class KeyValueIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateIndex(oplog, updated) {
|
updateIndex(oplog, updated) {
|
||||||
let handled = [];
|
updated.reverse().reduce((handled, item) => {
|
||||||
|
|
||||||
updated.reverse().forEach((item) => {
|
|
||||||
if(handled.indexOf(item.key) === -1) {
|
if(handled.indexOf(item.key) === -1) {
|
||||||
handled.push(item.key);
|
handled.push(item.key);
|
||||||
if(item.op === 'PUT') {
|
if(item.op === 'PUT') {
|
||||||
@ -21,7 +19,8 @@ class KeyValueIndex {
|
|||||||
delete this._index[item.key];
|
delete this._index[item.key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
return handled;
|
||||||
|
}, []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user