Chore: Bumps prettier version for new typescript syntax support (#20463)

* Chore: Bumps prettier version for new typescript syntax support

* Ran new version of prettier against the codebase
This commit is contained in:
kay delaney
2019-11-19 13:59:39 +00:00
committed by GitHub
parent af35e081c2
commit ca3dff99e8
141 changed files with 2277 additions and 867 deletions

View File

@@ -107,19 +107,16 @@ export function mergeTablesIntoModel(dst?: TableModel, ...tables: TableModel[]):
const columnNames: { [key: string]: any } = {};
// Union of all non-value columns
const columnsUnion = tableDataTables.slice().reduce(
(acc, series) => {
series.columns.forEach(col => {
const { text } = col;
if (columnNames[text] === undefined) {
columnNames[text] = acc.length;
acc.push(col);
}
});
return acc;
},
[] as MutableColumn[]
);
const columnsUnion = tableDataTables.slice().reduce((acc, series) => {
series.columns.forEach(col => {
const { text } = col;
if (columnNames[text] === undefined) {
columnNames[text] = acc.length;
acc.push(col);
}
});
return acc;
}, [] as MutableColumn[]);
// Map old column index to union index per series, e.g.,
// given columnNames {A: 0, B: 1} and
@@ -127,57 +124,51 @@ export function mergeTablesIntoModel(dst?: TableModel, ...tables: TableModel[]):
const columnIndexMapper = tableDataTables.map(series => series.columns.map(col => columnNames[col.text]));
// Flatten rows of all series and adjust new column indexes
const flattenedRows = tableDataTables.reduce(
(acc, series, seriesIndex) => {
const mapper = columnIndexMapper[seriesIndex];
series.rows.forEach(row => {
const alteredRow: MutableColumn[] = [];
// Shifting entries according to index mapper
mapper.forEach((to, from) => {
alteredRow[to] = row[from];
});
acc.push(alteredRow);
const flattenedRows = tableDataTables.reduce((acc, series, seriesIndex) => {
const mapper = columnIndexMapper[seriesIndex];
series.rows.forEach(row => {
const alteredRow: MutableColumn[] = [];
// Shifting entries according to index mapper
mapper.forEach((to, from) => {
alteredRow[to] = row[from];
});
return acc;
},
[] as MutableColumn[][]
);
acc.push(alteredRow);
});
return acc;
}, [] as MutableColumn[][]);
// Merge rows that have same values for columns
const mergedRows: { [key: string]: any } = {};
const compactedRows = flattenedRows.reduce(
(acc, row, rowIndex) => {
if (!mergedRows[rowIndex]) {
// Look from current row onwards
let offset = rowIndex + 1;
// More than one row can be merged into current row
while (offset < flattenedRows.length) {
// Find next row that could be merged
const match = _.findIndex(flattenedRows, otherRow => areRowsMatching(columnsUnion, row, otherRow), offset);
if (match > -1) {
const matchedRow = flattenedRows[match];
// Merge values from match into current row if there is a gap in the current row
for (let columnIndex = 0; columnIndex < columnsUnion.length; columnIndex++) {
if (row[columnIndex] === undefined && matchedRow[columnIndex] !== undefined) {
row[columnIndex] = matchedRow[columnIndex];
}
const compactedRows = flattenedRows.reduce((acc, row, rowIndex) => {
if (!mergedRows[rowIndex]) {
// Look from current row onwards
let offset = rowIndex + 1;
// More than one row can be merged into current row
while (offset < flattenedRows.length) {
// Find next row that could be merged
const match = _.findIndex(flattenedRows, otherRow => areRowsMatching(columnsUnion, row, otherRow), offset);
if (match > -1) {
const matchedRow = flattenedRows[match];
// Merge values from match into current row if there is a gap in the current row
for (let columnIndex = 0; columnIndex < columnsUnion.length; columnIndex++) {
if (row[columnIndex] === undefined && matchedRow[columnIndex] !== undefined) {
row[columnIndex] = matchedRow[columnIndex];
}
// Don't visit this row again
mergedRows[match] = matchedRow;
// Keep looking for more rows to merge
offset = match + 1;
} else {
// No match found, stop looking
break;
}
// Don't visit this row again
mergedRows[match] = matchedRow;
// Keep looking for more rows to merge
offset = match + 1;
} else {
// No match found, stop looking
break;
}
acc.push(row);
}
return acc;
},
[] as MutableColumn[][]
);
acc.push(row);
}
return acc;
}, [] as MutableColumn[][]);
model.columns = columnsUnion;
model.rows = compactedRows;