Skip to content

Commit

Permalink
chore: use forEach instead of reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
jajugoguma committed May 25, 2023
1 parent 7f155bc commit 2f68f36
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ export function createManager(): ModifiedDataManager {
return acc;
}, []);

sortedContinuousIndexedRows.reduce((accLength, indexedRows) => {
let accumulatedLength = 0;

sortedContinuousIndexedRows.forEach((indexedRows) => {
const startIndex = indexedRows[0].rowIndex;
const currentLength = last(indexedRows).rowIndex - startIndex + 1;

if (isUndefined(rows)) {
dataMap[type].splice(startIndex - accLength, currentLength);
dataMap[type].splice(startIndex - accumulatedLength, currentLength);
} else {
dataMap[type].splice(
startIndex,
Expand All @@ -115,8 +117,8 @@ export function createManager(): ModifiedDataManager {
);
}

return accLength + currentLength;
}, 0);
accumulatedLength += currentLength;
});
};
const spliceAll = (rowKey: RowKey, row?: Row) => {
splice('CREATE', [rowKey], !row ? row : [row]);
Expand Down

0 comments on commit 2f68f36

Please sign in to comment.