minimal adjustments
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / table / dist / table.js
1 "use strict";
2
3 Object.defineProperty(exports, "__esModule", {
4   value: true
5 });
6 exports.default = void 0;
7
8 var _alignTableData = _interopRequireDefault(require("./alignTableData"));
9
10 var _calculateCellWidthIndex = _interopRequireDefault(require("./calculateCellWidthIndex"));
11
12 var _calculateRowHeightIndex = _interopRequireDefault(require("./calculateRowHeightIndex"));
13
14 var _drawTable = _interopRequireDefault(require("./drawTable"));
15
16 var _makeConfig = _interopRequireDefault(require("./makeConfig"));
17
18 var _mapDataUsingRowHeightIndex = _interopRequireDefault(require("./mapDataUsingRowHeightIndex"));
19
20 var _padTableData = _interopRequireDefault(require("./padTableData"));
21
22 var _stringifyTableData = _interopRequireDefault(require("./stringifyTableData"));
23
24 var _truncateTableData = _interopRequireDefault(require("./truncateTableData"));
25
26 var _validateTableData = _interopRequireDefault(require("./validateTableData"));
27
28 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
30 /**
31  * @typedef {string} table~cell
32  */
33
34 /**
35  * @typedef {table~cell[]} table~row
36  */
37
38 /**
39  * @typedef {object} table~columns
40  * @property {string} alignment Cell content alignment (enum: left, center, right) (default: left).
41  * @property {number} width Column width (default: auto).
42  * @property {number} truncate Number of characters are which the content will be truncated (default: Infinity).
43  * @property {boolean} wrapWord When true the text is broken at the nearest space or one of the special characters
44  * @property {number} paddingLeft Cell content padding width left (default: 1).
45  * @property {number} paddingRight Cell content padding width right (default: 1).
46  */
47
48 /**
49  * @typedef {object} table~border
50  * @property {string} topBody
51  * @property {string} topJoin
52  * @property {string} topLeft
53  * @property {string} topRight
54  * @property {string} bottomBody
55  * @property {string} bottomJoin
56  * @property {string} bottomLeft
57  * @property {string} bottomRight
58  * @property {string} bodyLeft
59  * @property {string} bodyRight
60  * @property {string} bodyJoin
61  * @property {string} joinBody
62  * @property {string} joinLeft
63  * @property {string} joinRight
64  * @property {string} joinJoin
65  */
66
67 /**
68  * Used to tell whether to draw a horizontal line.
69  * This callback is called for each non-content line of the table.
70  * The default behavior is to always return true.
71  *
72  * @typedef {Function} drawHorizontalLine
73  * @param {number} index
74  * @param {number} size
75  * @returns {boolean}
76  */
77
78 /**
79  * @typedef {object} table~config
80  * @property {table~border} border
81  * @property {table~columns[]} columns Column specific configuration.
82  * @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values.
83  * @property {table~drawHorizontalLine} drawHorizontalLine
84  * @property {table~singleLine} singleLine Horizontal lines inside the table are not drawn.
85  */
86
87 /**
88  * Generates a text table.
89  *
90  * @param {table~row[]} data
91  * @param {table~config} userConfig
92  * @returns {string}
93  */
94 const table = (data, userConfig = {}) => {
95   let rows;
96   (0, _validateTableData.default)(data);
97   rows = (0, _stringifyTableData.default)(data);
98   const config = (0, _makeConfig.default)(rows, userConfig);
99   rows = (0, _truncateTableData.default)(data, config);
100   const rowHeightIndex = (0, _calculateRowHeightIndex.default)(rows, config);
101   rows = (0, _mapDataUsingRowHeightIndex.default)(rows, rowHeightIndex, config);
102   rows = (0, _alignTableData.default)(rows, config);
103   rows = (0, _padTableData.default)(rows, config);
104   const cellWidthIndex = (0, _calculateCellWidthIndex.default)(rows[0]);
105   return (0, _drawTable.default)(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine, config.singleLine);
106 };
107
108 var _default = table;
109 exports.default = _default;
110 //# sourceMappingURL=table.js.map