1 import calculateCellWidthIndex from './calculateCellWidthIndex';
4 * Produces an array of values that describe the largest value length (width) in every column.
6 * @param {Array[]} rows
9 export default (rows) => {
11 throw new Error('Dataset must have at least one row.');
14 const columns = new Array(rows[0].length).fill(0);
16 rows.forEach((row) => {
17 const columnWidthIndex = calculateCellWidthIndex(row);
19 columnWidthIndex.forEach((valueWidth, index0) => {
20 if (columns[index0] < valueWidth) {
21 columns[index0] = valueWidth;