Skip to content

Commit

Permalink
deep copying by looping rather than stringifying and gitignoring inte…
Browse files Browse the repository at this point in the history
…llij files
  • Loading branch information
pat310 committed Nov 23, 2017
1 parent 67df225 commit e523ce6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ test.js

# Ignore mac files
.DS_Store

# ignore intellij stuff
.idea
11 changes: 9 additions & 2 deletions src/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,15 @@ export function tableCreator(data, rows = [], cols = [], accCatOrCB,
type: 'aggregated',
};

// TODO: fix this horrible hack of deep cloning object
const colHeadersCopy = JSON.parse(JSON.stringify(formattedColumnHeaders));
const colHeadersValueCopies = formattedColumnHeaders.map(({ value }) => {
return Object.assign([], value);
});
const colHeadersCopy = formattedColumnHeaders.map((colHeaderObj, i) => {
const copy = Object.assign({}, colHeaderObj);

copy.value = colHeadersValueCopies[i];
return copy;
});

let counter = 0;
const table = colHeadersCopy.concat(dataRows, accumulatedRows)
Expand Down

0 comments on commit e523ce6

Please sign in to comment.