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

This commit is contained in:
haad 2016-05-04 11:30:37 +02:00
parent 3c4fc90819
commit d823ab4d2b

View File

@ -10,18 +10,17 @@ class KeyValueIndex {
}
updateIndex(oplog, updated) {
let handled = [];
updated.reverse().forEach((item) => {
updated.reverse().reduce((handled, item) => {
if(handled.indexOf(item.key) === -1) {
handled.push(item.key);
if(item.op === 'PUT') {
this._index[item.key] = item.value
} else if (item.op === 'DEL') {
} else if(item.op === 'DEL') {
delete this._index[item.key];
}
}
});
return handled;
}, []);
}
}