table 3.8.2 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -16
- package/dist/alignString.js +19 -842
- package/dist/alignTableData.js +4 -226
- package/dist/calculateCellHeight.js +6 -343
- package/dist/calculateCellWidthIndex.js +2 -112
- package/dist/calculateMaximumColumnWidthIndex.js +5 -299
- package/dist/calculateRowHeightIndex.js +8 -333
- package/dist/createStream.js +19 -814
- package/dist/drawBorder.js +11 -292
- package/dist/drawRow.js +1 -69
- package/dist/drawTable.js +7 -474
- package/dist/getBorderCharacters.js +1 -315
- package/dist/index.js +4 -28
- package/dist/makeConfig.js +15 -544
- package/dist/makeStreamConfig.js +13 -587
- package/dist/mapDataUsingRowHeightIndex.js +9 -349
- package/dist/padTableData.js +5 -166
- package/dist/schemas/config.json +2 -2
- package/dist/schemas/streamConfig.json +2 -2
- package/dist/stringifyTableData.js +4 -116
- package/dist/table.js +5 -203
- package/dist/truncateTableData.js +3 -147
- package/dist/validateConfig.js +20 -23
- package/dist/validateStreamConfig.js +17 -19
- package/dist/validateTableData.js +11 -528
- package/dist/wrapString.js +3 -135
- package/dist/wrapWord.js +4 -257
- package/package.json +27 -24
- package/test/README/usage/basic.js +0 -25
- package/test/README/usage/cell_content_alignment.js +0 -45
- package/test/README/usage/column_width.js +0 -33
- package/test/README/usage/custom_border.js +0 -50
- package/test/README/usage/draw_horizontal_line.js +0 -41
- package/test/README/usage/expectTable.js +0 -13
- package/test/README/usage/moon_mission.js +0 -67
- package/test/README/usage/padding_cell_content.js +0 -39
- package/test/README/usage/predefined_border_templates.js +0 -91
- package/test/README/usage/streaming.js +0 -56
- package/test/README/usage/text_truncating.js +0 -32
- package/test/README/usage/text_wrapping.js +0 -67
- package/test/alignString.js +0 -102
- package/test/calculateCellHeight.js +0 -44
- package/test/calculateCellWidthIndex.js +0 -20
- package/test/calculateMaximumColumnWidthIndex.js +0 -59
- package/test/calculateRowHeightIndex.js +0 -78
- package/test/config.js +0 -43
- package/test/configSamples.js +0 -153
- package/test/createStream.js +0 -41
- package/test/drawBorder.js +0 -71
- package/test/makeConfig.js +0 -75
- package/test/mapDataUsingRowHeightIndex.js +0 -119
- package/test/streamConfig.js +0 -43
- package/test/streamConfigSamples.js +0 -151
- package/test/validateTableData.js +0 -65
- package/test/wrapString.js +0 -45
- package/test/wrapWord.js +0 -32
|
@@ -4,306 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var cov_161lflitbr = function () {
|
|
8
|
-
var path = '/Users/gajuskuizinas/Documents/dev/gajus/table/src/calculateRowHeightIndex.js',
|
|
9
|
-
hash = '3ea7effa044c58c1829012ae1f0f20e85671abbe',
|
|
10
|
-
global = new Function('return this')(),
|
|
11
|
-
gcv = '__coverage__',
|
|
12
|
-
coverageData = {
|
|
13
|
-
path: '/Users/gajuskuizinas/Documents/dev/gajus/table/src/calculateRowHeightIndex.js',
|
|
14
|
-
statementMap: {
|
|
15
|
-
'0': {
|
|
16
|
-
start: {
|
|
17
|
-
line: 12,
|
|
18
|
-
column: 21
|
|
19
|
-
},
|
|
20
|
-
end: {
|
|
21
|
-
line: 12,
|
|
22
|
-
column: 35
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
'1': {
|
|
26
|
-
start: {
|
|
27
|
-
line: 14,
|
|
28
|
-
column: 23
|
|
29
|
-
},
|
|
30
|
-
end: {
|
|
31
|
-
line: 14,
|
|
32
|
-
column: 25
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
'2': {
|
|
36
|
-
start: {
|
|
37
|
-
line: 16,
|
|
38
|
-
column: 2
|
|
39
|
-
},
|
|
40
|
-
end: {
|
|
41
|
-
line: 32,
|
|
42
|
-
column: 5
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
'3': {
|
|
46
|
-
start: {
|
|
47
|
-
line: 17,
|
|
48
|
-
column: 28
|
|
49
|
-
},
|
|
50
|
-
end: {
|
|
51
|
-
line: 17,
|
|
52
|
-
column: 56
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
'4': {
|
|
56
|
-
start: {
|
|
57
|
-
line: 19,
|
|
58
|
-
column: 4
|
|
59
|
-
},
|
|
60
|
-
end: {
|
|
61
|
-
line: 29,
|
|
62
|
-
column: 7
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
'5': {
|
|
66
|
-
start: {
|
|
67
|
-
line: 20,
|
|
68
|
-
column: 6
|
|
69
|
-
},
|
|
70
|
-
end: {
|
|
71
|
-
line: 22,
|
|
72
|
-
column: 7
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
'6': {
|
|
76
|
-
start: {
|
|
77
|
-
line: 21,
|
|
78
|
-
column: 8
|
|
79
|
-
},
|
|
80
|
-
end: {
|
|
81
|
-
line: 21,
|
|
82
|
-
column: 65
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
'7': {
|
|
86
|
-
start: {
|
|
87
|
-
line: 24,
|
|
88
|
-
column: 6
|
|
89
|
-
},
|
|
90
|
-
end: {
|
|
91
|
-
line: 26,
|
|
92
|
-
column: 7
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
'8': {
|
|
96
|
-
start: {
|
|
97
|
-
line: 25,
|
|
98
|
-
column: 8
|
|
99
|
-
},
|
|
100
|
-
end: {
|
|
101
|
-
line: 25,
|
|
102
|
-
column: 69
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
'9': {
|
|
106
|
-
start: {
|
|
107
|
-
line: 28,
|
|
108
|
-
column: 6
|
|
109
|
-
},
|
|
110
|
-
end: {
|
|
111
|
-
line: 28,
|
|
112
|
-
column: 122
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
'10': {
|
|
116
|
-
start: {
|
|
117
|
-
line: 31,
|
|
118
|
-
column: 4
|
|
119
|
-
},
|
|
120
|
-
end: {
|
|
121
|
-
line: 31,
|
|
122
|
-
column: 46
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
'11': {
|
|
126
|
-
start: {
|
|
127
|
-
line: 34,
|
|
128
|
-
column: 2
|
|
129
|
-
},
|
|
130
|
-
end: {
|
|
131
|
-
line: 34,
|
|
132
|
-
column: 22
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
fnMap: {
|
|
137
|
-
'0': {
|
|
138
|
-
name: '(anonymous_0)',
|
|
139
|
-
decl: {
|
|
140
|
-
start: {
|
|
141
|
-
line: 11,
|
|
142
|
-
column: 15
|
|
143
|
-
},
|
|
144
|
-
end: {
|
|
145
|
-
line: 11,
|
|
146
|
-
column: 16
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
loc: {
|
|
150
|
-
start: {
|
|
151
|
-
line: 11,
|
|
152
|
-
column: 33
|
|
153
|
-
},
|
|
154
|
-
end: {
|
|
155
|
-
line: 35,
|
|
156
|
-
column: 1
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
'1': {
|
|
161
|
-
name: '(anonymous_1)',
|
|
162
|
-
decl: {
|
|
163
|
-
start: {
|
|
164
|
-
line: 16,
|
|
165
|
-
column: 18
|
|
166
|
-
},
|
|
167
|
-
end: {
|
|
168
|
-
line: 16,
|
|
169
|
-
column: 19
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
loc: {
|
|
173
|
-
start: {
|
|
174
|
-
line: 16,
|
|
175
|
-
column: 29
|
|
176
|
-
},
|
|
177
|
-
end: {
|
|
178
|
-
line: 32,
|
|
179
|
-
column: 3
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
'2': {
|
|
184
|
-
name: '(anonymous_2)',
|
|
185
|
-
decl: {
|
|
186
|
-
start: {
|
|
187
|
-
line: 19,
|
|
188
|
-
column: 21
|
|
189
|
-
},
|
|
190
|
-
end: {
|
|
191
|
-
line: 19,
|
|
192
|
-
column: 22
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
loc: {
|
|
196
|
-
start: {
|
|
197
|
-
line: 19,
|
|
198
|
-
column: 40
|
|
199
|
-
},
|
|
200
|
-
end: {
|
|
201
|
-
line: 29,
|
|
202
|
-
column: 5
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
branchMap: {
|
|
208
|
-
'0': {
|
|
209
|
-
loc: {
|
|
210
|
-
start: {
|
|
211
|
-
line: 20,
|
|
212
|
-
column: 6
|
|
213
|
-
},
|
|
214
|
-
end: {
|
|
215
|
-
line: 22,
|
|
216
|
-
column: 7
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
type: 'if',
|
|
220
|
-
locations: [{
|
|
221
|
-
start: {
|
|
222
|
-
line: 20,
|
|
223
|
-
column: 6
|
|
224
|
-
},
|
|
225
|
-
end: {
|
|
226
|
-
line: 22,
|
|
227
|
-
column: 7
|
|
228
|
-
}
|
|
229
|
-
}, {
|
|
230
|
-
start: {
|
|
231
|
-
line: 20,
|
|
232
|
-
column: 6
|
|
233
|
-
},
|
|
234
|
-
end: {
|
|
235
|
-
line: 22,
|
|
236
|
-
column: 7
|
|
237
|
-
}
|
|
238
|
-
}]
|
|
239
|
-
},
|
|
240
|
-
'1': {
|
|
241
|
-
loc: {
|
|
242
|
-
start: {
|
|
243
|
-
line: 24,
|
|
244
|
-
column: 6
|
|
245
|
-
},
|
|
246
|
-
end: {
|
|
247
|
-
line: 26,
|
|
248
|
-
column: 7
|
|
249
|
-
}
|
|
250
|
-
},
|
|
251
|
-
type: 'if',
|
|
252
|
-
locations: [{
|
|
253
|
-
start: {
|
|
254
|
-
line: 24,
|
|
255
|
-
column: 6
|
|
256
|
-
},
|
|
257
|
-
end: {
|
|
258
|
-
line: 26,
|
|
259
|
-
column: 7
|
|
260
|
-
}
|
|
261
|
-
}, {
|
|
262
|
-
start: {
|
|
263
|
-
line: 24,
|
|
264
|
-
column: 6
|
|
265
|
-
},
|
|
266
|
-
end: {
|
|
267
|
-
line: 26,
|
|
268
|
-
column: 7
|
|
269
|
-
}
|
|
270
|
-
}]
|
|
271
|
-
}
|
|
272
|
-
},
|
|
273
|
-
s: {
|
|
274
|
-
'0': 0,
|
|
275
|
-
'1': 0,
|
|
276
|
-
'2': 0,
|
|
277
|
-
'3': 0,
|
|
278
|
-
'4': 0,
|
|
279
|
-
'5': 0,
|
|
280
|
-
'6': 0,
|
|
281
|
-
'7': 0,
|
|
282
|
-
'8': 0,
|
|
283
|
-
'9': 0,
|
|
284
|
-
'10': 0,
|
|
285
|
-
'11': 0
|
|
286
|
-
},
|
|
287
|
-
f: {
|
|
288
|
-
'0': 0,
|
|
289
|
-
'1': 0,
|
|
290
|
-
'2': 0
|
|
291
|
-
},
|
|
292
|
-
b: {
|
|
293
|
-
'0': [0, 0],
|
|
294
|
-
'1': [0, 0]
|
|
295
|
-
}
|
|
296
|
-
},
|
|
297
|
-
coverage = global[gcv] || (global[gcv] = {});
|
|
298
|
-
|
|
299
|
-
if (coverage[path] && coverage[path].hash === hash) {
|
|
300
|
-
return coverage[path];
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
coverageData.hash = hash;
|
|
304
|
-
return coverage[path] = coverageData;
|
|
305
|
-
}();
|
|
306
|
-
|
|
307
7
|
var _lodash = require('lodash');
|
|
308
8
|
|
|
309
9
|
var _lodash2 = _interopRequireDefault(_lodash);
|
|
@@ -322,52 +22,27 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
322
22
|
* @returns {number[]}
|
|
323
23
|
*/
|
|
324
24
|
exports.default = (rows, config) => {
|
|
325
|
-
|
|
25
|
+
const tableWidth = rows[0].length;
|
|
326
26
|
|
|
327
|
-
const
|
|
27
|
+
const rowSpanIndex = [];
|
|
328
28
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
++cov_161lflitbr.s[2];
|
|
332
|
-
_lodash2.default.forEach(rows, cells => {
|
|
333
|
-
++cov_161lflitbr.f[1];
|
|
334
|
-
|
|
335
|
-
const cellHeightIndex = (++cov_161lflitbr.s[3], _lodash2.default.fill(Array(tableWidth), 1));
|
|
336
|
-
|
|
337
|
-
++cov_161lflitbr.s[4];
|
|
338
|
-
_lodash2.default.forEach(cells, (value, index1) => {
|
|
339
|
-
++cov_161lflitbr.f[2];
|
|
340
|
-
++cov_161lflitbr.s[5];
|
|
29
|
+
rows.forEach(cells => {
|
|
30
|
+
const cellHeightIndex = Array(tableWidth).fill(1);
|
|
341
31
|
|
|
32
|
+
cells.forEach((value, index1) => {
|
|
342
33
|
if (!_lodash2.default.isNumber(config.columns[index1].width)) {
|
|
343
|
-
|
|
344
|
-
++cov_161lflitbr.s[6];
|
|
345
|
-
|
|
346
|
-
throw new Error('column[index].width must be a number.');
|
|
347
|
-
} else {
|
|
348
|
-
++cov_161lflitbr.b[0][1];
|
|
34
|
+
throw new TypeError('column[index].width must be a number.');
|
|
349
35
|
}
|
|
350
36
|
|
|
351
|
-
++cov_161lflitbr.s[7];
|
|
352
37
|
if (!_lodash2.default.isBoolean(config.columns[index1].wrapWord)) {
|
|
353
|
-
|
|
354
|
-
++cov_161lflitbr.s[8];
|
|
355
|
-
|
|
356
|
-
throw new Error('column[index].wrapWord must be a boolean.');
|
|
357
|
-
} else {
|
|
358
|
-
++cov_161lflitbr.b[1][1];
|
|
38
|
+
throw new TypeError('column[index].wrapWord must be a boolean.');
|
|
359
39
|
}
|
|
360
40
|
|
|
361
|
-
++cov_161lflitbr.s[9];
|
|
362
41
|
cellHeightIndex[index1] = (0, _calculateCellHeight2.default)(value, config.columns[index1].width, config.columns[index1].wrapWord);
|
|
363
42
|
});
|
|
364
43
|
|
|
365
|
-
++cov_161lflitbr.s[10];
|
|
366
44
|
rowSpanIndex.push(_lodash2.default.max(cellHeightIndex));
|
|
367
45
|
});
|
|
368
46
|
|
|
369
|
-
++cov_161lflitbr.s[11];
|
|
370
47
|
return rowSpanIndex;
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
module.exports = exports['default'];
|
|
48
|
+
};
|