Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / table / dist / calculateRowHeightIndex.js.flow
1 import _ from 'lodash';
2 import calculateCellHeight from './calculateCellHeight';
3
4 /**
5  * Calculates the vertical row span index.
6  *
7  * @param {Array[]} rows
8  * @param {Object} config
9  * @returns {number[]}
10  */
11 export default (rows, config) => {
12   const tableWidth = rows[0].length;
13
14   const rowSpanIndex = [];
15
16   rows.forEach((cells) => {
17     const cellHeightIndex = new Array(tableWidth).fill(1);
18
19     cells.forEach((value, index1) => {
20       if (!_.isNumber(config.columns[index1].width)) {
21         throw new TypeError('column[index].width must be a number.');
22       }
23
24       if (!_.isBoolean(config.columns[index1].wrapWord)) {
25         throw new TypeError('column[index].wrapWord must be a boolean.');
26       }
27
28       cellHeightIndex[index1] = calculateCellHeight(value, config.columns[index1].width, config.columns[index1].wrapWord);
29     });
30
31     rowSpanIndex.push(_.max(cellHeightIndex));
32   });
33
34   return rowSpanIndex;
35 };