minimal adjustments
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / table / dist / mapDataUsingRowHeightIndex.js
1 "use strict";
2
3 Object.defineProperty(exports, "__esModule", {
4   value: true
5 });
6 exports.default = void 0;
7
8 var _lodash = _interopRequireDefault(require("lodash.flatten"));
9
10 var _wrapCell = _interopRequireDefault(require("./wrapCell"));
11
12 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14 /**
15  * @param {Array} unmappedRows
16  * @param {number[]} rowHeightIndex
17  * @param {object} config
18  * @returns {Array}
19  */
20 const mapDataUsingRowHeightIndex = (unmappedRows, rowHeightIndex, config) => {
21   const tableWidth = unmappedRows[0].length;
22   const mappedRows = unmappedRows.map((cells, index0) => {
23     const rowHeight = Array.from(new Array(rowHeightIndex[index0]), () => {
24       return new Array(tableWidth).fill('');
25     }); // rowHeight
26     //     [{row index within rowSaw; index2}]
27     //     [{cell index within a virtual row; index1}]
28
29     cells.forEach((value, index1) => {
30       const cellLines = (0, _wrapCell.default)(value, config.columns[index1].width, config.columns[index1].wrapWord);
31       cellLines.forEach((cellLine, index2) => {
32         rowHeight[index2][index1] = cellLine;
33       });
34     });
35     return rowHeight;
36   });
37   return (0, _lodash.default)(mappedRows);
38 };
39
40 var _default = mapDataUsingRowHeightIndex;
41 exports.default = _default;
42 //# sourceMappingURL=mapDataUsingRowHeightIndex.js.map