.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / node_modules / table / dist / calculateRowHeightIndex.js
1 'use strict';
2
3 Object.defineProperty(exports, "__esModule", {
4   value: true
5 });
6
7 var _lodash = require('lodash');
8
9 var _lodash2 = _interopRequireDefault(_lodash);
10
11 var _calculateCellHeight = require('./calculateCellHeight');
12
13 var _calculateCellHeight2 = _interopRequireDefault(_calculateCellHeight);
14
15 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
17 /**
18  * Calculates the vertical row span index.
19  *
20  * @param {Array[]} rows
21  * @param {Object} config
22  * @returns {number[]}
23  */
24 exports.default = (rows, config) => {
25   const tableWidth = rows[0].length;
26
27   const rowSpanIndex = [];
28
29   rows.forEach(cells => {
30     const cellHeightIndex = Array(tableWidth).fill(1);
31
32     cells.forEach((value, index1) => {
33       if (!_lodash2.default.isNumber(config.columns[index1].width)) {
34         throw new TypeError('column[index].width must be a number.');
35       }
36
37       if (!_lodash2.default.isBoolean(config.columns[index1].wrapWord)) {
38         throw new TypeError('column[index].wrapWord must be a boolean.');
39       }
40
41       cellHeightIndex[index1] = (0, _calculateCellHeight2.default)(value, config.columns[index1].width, config.columns[index1].wrapWord);
42     });
43
44     rowSpanIndex.push(_lodash2.default.max(cellHeightIndex));
45   });
46
47   return rowSpanIndex;
48 };