.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / node_modules / table / dist / drawTable.js
1 'use strict';
2
3 Object.defineProperty(exports, "__esModule", {
4   value: true
5 });
6
7 var _drawBorder = require('./drawBorder');
8
9 var _drawRow = require('./drawRow');
10
11 var _drawRow2 = _interopRequireDefault(_drawRow);
12
13 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15 /**
16  * @param {Array} rows
17  * @param {Object} border
18  * @param {Array} columnSizeIndex
19  * @param {Array} rowSpanIndex
20  * @param {Function} drawHorizontalLine
21  * @returns {string}
22  */
23 exports.default = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => {
24   let output;
25   let realRowIndex;
26   let rowHeight;
27
28   const rowCount = rows.length;
29
30   realRowIndex = 0;
31
32   output = '';
33
34   if (drawHorizontalLine(realRowIndex, rowCount)) {
35     output += (0, _drawBorder.drawBorderTop)(columnSizeIndex, border);
36   }
37
38   rows.forEach((row, index0) => {
39     output += (0, _drawRow2.default)(row, border);
40
41     if (!rowHeight) {
42       rowHeight = rowSpanIndex[realRowIndex];
43
44       realRowIndex++;
45     }
46
47     rowHeight--;
48
49     if (rowHeight === 0 && index0 !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) {
50       output += (0, _drawBorder.drawBorderJoin)(columnSizeIndex, border);
51     }
52   });
53
54   if (drawHorizontalLine(realRowIndex, rowCount)) {
55     output += (0, _drawBorder.drawBorderBottom)(columnSizeIndex, border);
56   }
57
58   return output;
59 };