Use reduce() instead of forEach() for building EventIndex

This commit is contained in:
haad 2016-05-04 11:28:44 +02:00
parent 2b8b5f0285
commit 3c4fc90819

View File

@ -10,9 +10,7 @@ class EventIndex {
} }
updateIndex(oplog, updated) { updateIndex(oplog, updated) {
let handled = []; updated.reduce((handled, item) => {
updated.forEach((item) => {
if(handled.indexOf(item.hash) === -1) { if(handled.indexOf(item.hash) === -1) {
handled.push(item.hash); handled.push(item.hash);
if(item.op === 'ADD') { if(item.op === 'ADD') {
@ -21,7 +19,8 @@ class EventIndex {
delete this._index[item.value]; delete this._index[item.value];
} }
} }
}); return handled;
}, []);
} }
} }