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.
Files changed (56) hide show
  1. package/README.md +35 -16
  2. package/dist/alignString.js +19 -842
  3. package/dist/alignTableData.js +4 -226
  4. package/dist/calculateCellHeight.js +6 -343
  5. package/dist/calculateCellWidthIndex.js +2 -112
  6. package/dist/calculateMaximumColumnWidthIndex.js +5 -299
  7. package/dist/calculateRowHeightIndex.js +8 -333
  8. package/dist/createStream.js +19 -814
  9. package/dist/drawBorder.js +11 -292
  10. package/dist/drawRow.js +1 -69
  11. package/dist/drawTable.js +7 -474
  12. package/dist/getBorderCharacters.js +1 -315
  13. package/dist/index.js +4 -28
  14. package/dist/makeConfig.js +15 -544
  15. package/dist/makeStreamConfig.js +13 -587
  16. package/dist/mapDataUsingRowHeightIndex.js +9 -349
  17. package/dist/padTableData.js +5 -166
  18. package/dist/schemas/config.json +2 -2
  19. package/dist/schemas/streamConfig.json +2 -2
  20. package/dist/stringifyTableData.js +4 -116
  21. package/dist/table.js +5 -203
  22. package/dist/truncateTableData.js +3 -147
  23. package/dist/validateConfig.js +20 -23
  24. package/dist/validateStreamConfig.js +17 -19
  25. package/dist/validateTableData.js +11 -528
  26. package/dist/wrapString.js +3 -135
  27. package/dist/wrapWord.js +4 -257
  28. package/package.json +27 -24
  29. package/test/README/usage/basic.js +0 -25
  30. package/test/README/usage/cell_content_alignment.js +0 -45
  31. package/test/README/usage/column_width.js +0 -33
  32. package/test/README/usage/custom_border.js +0 -50
  33. package/test/README/usage/draw_horizontal_line.js +0 -41
  34. package/test/README/usage/expectTable.js +0 -13
  35. package/test/README/usage/moon_mission.js +0 -67
  36. package/test/README/usage/padding_cell_content.js +0 -39
  37. package/test/README/usage/predefined_border_templates.js +0 -91
  38. package/test/README/usage/streaming.js +0 -56
  39. package/test/README/usage/text_truncating.js +0 -32
  40. package/test/README/usage/text_wrapping.js +0 -67
  41. package/test/alignString.js +0 -102
  42. package/test/calculateCellHeight.js +0 -44
  43. package/test/calculateCellWidthIndex.js +0 -20
  44. package/test/calculateMaximumColumnWidthIndex.js +0 -59
  45. package/test/calculateRowHeightIndex.js +0 -78
  46. package/test/config.js +0 -43
  47. package/test/configSamples.js +0 -153
  48. package/test/createStream.js +0 -41
  49. package/test/drawBorder.js +0 -71
  50. package/test/makeConfig.js +0 -75
  51. package/test/mapDataUsingRowHeightIndex.js +0 -119
  52. package/test/streamConfig.js +0 -43
  53. package/test/streamConfigSamples.js +0 -151
  54. package/test/validateTableData.js +0 -65
  55. package/test/wrapString.js +0 -45
  56. package/test/wrapWord.js +0 -32
@@ -4,108 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var cov_1fd7vh0l3t = function () {
8
- var path = '/Users/gajuskuizinas/Documents/dev/gajus/table/src/calculateCellWidthIndex.js',
9
- hash = 'b9600d2c169ef60a6ea737b6fcbbb85c260df86f',
10
- global = new Function('return this')(),
11
- gcv = '__coverage__',
12
- coverageData = {
13
- path: '/Users/gajuskuizinas/Documents/dev/gajus/table/src/calculateCellWidthIndex.js',
14
- statementMap: {
15
- '0': {
16
- start: {
17
- line: 11,
18
- column: 2
19
- },
20
- end: {
21
- line: 13,
22
- column: 5
23
- }
24
- },
25
- '1': {
26
- start: {
27
- line: 12,
28
- column: 4
29
- },
30
- end: {
31
- line: 12,
32
- column: 30
33
- }
34
- }
35
- },
36
- fnMap: {
37
- '0': {
38
- name: '(anonymous_0)',
39
- decl: {
40
- start: {
41
- line: 10,
42
- column: 15
43
- },
44
- end: {
45
- line: 10,
46
- column: 16
47
- }
48
- },
49
- loc: {
50
- start: {
51
- line: 10,
52
- column: 26
53
- },
54
- end: {
55
- line: 14,
56
- column: 1
57
- }
58
- }
59
- },
60
- '1': {
61
- name: '(anonymous_1)',
62
- decl: {
63
- start: {
64
- line: 11,
65
- column: 22
66
- },
67
- end: {
68
- line: 11,
69
- column: 23
70
- }
71
- },
72
- loc: {
73
- start: {
74
- line: 11,
75
- column: 33
76
- },
77
- end: {
78
- line: 13,
79
- column: 3
80
- }
81
- }
82
- }
83
- },
84
- branchMap: {},
85
- s: {
86
- '0': 0,
87
- '1': 0
88
- },
89
- f: {
90
- '0': 0,
91
- '1': 0
92
- },
93
- b: {}
94
- },
95
- coverage = global[gcv] || (global[gcv] = {});
96
-
97
- if (coverage[path] && coverage[path].hash === hash) {
98
- return coverage[path];
99
- }
100
-
101
- coverageData.hash = hash;
102
- return coverage[path] = coverageData;
103
- }();
104
-
105
- var _lodash = require('lodash');
106
-
107
- var _lodash2 = _interopRequireDefault(_lodash);
108
-
109
7
  var _stringWidth = require('string-width');
110
8
 
111
9
  var _stringWidth2 = _interopRequireDefault(_stringWidth);
@@ -119,15 +17,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
119
17
  * @returns {number[]}
120
18
  */
121
19
  exports.default = cells => {
122
- ++cov_1fd7vh0l3t.f[0];
123
- ++cov_1fd7vh0l3t.s[0];
124
-
125
- return _lodash2.default.map(cells, value => {
126
- ++cov_1fd7vh0l3t.f[1];
127
- ++cov_1fd7vh0l3t.s[1];
128
-
20
+ return cells.map(value => {
129
21
  return (0, _stringWidth2.default)(value);
130
22
  });
131
- };
132
-
133
- module.exports = exports['default'];
23
+ };
@@ -4,277 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var cov_qyqm9cd68 = function () {
8
- var path = '/Users/gajuskuizinas/Documents/dev/gajus/table/src/calculateMaximumColumnWidthIndex.js',
9
- hash = '879c5b124d777a0bf46104f942ca9def05c6c3af',
10
- global = new Function('return this')(),
11
- gcv = '__coverage__',
12
- coverageData = {
13
- path: '/Users/gajuskuizinas/Documents/dev/gajus/table/src/calculateMaximumColumnWidthIndex.js',
14
- statementMap: {
15
- '0': {
16
- start: {
17
- line: 11,
18
- column: 2
19
- },
20
- end: {
21
- line: 13,
22
- column: 3
23
- }
24
- },
25
- '1': {
26
- start: {
27
- line: 12,
28
- column: 4
29
- },
30
- end: {
31
- line: 12,
32
- column: 59
33
- }
34
- },
35
- '2': {
36
- start: {
37
- line: 15,
38
- column: 18
39
- },
40
- end: {
41
- line: 15,
42
- column: 50
43
- }
44
- },
45
- '3': {
46
- start: {
47
- line: 17,
48
- column: 2
49
- },
50
- end: {
51
- line: 25,
52
- column: 5
53
- }
54
- },
55
- '4': {
56
- start: {
57
- line: 18,
58
- column: 29
59
- },
60
- end: {
61
- line: 18,
62
- column: 57
63
- }
64
- },
65
- '5': {
66
- start: {
67
- line: 20,
68
- column: 4
69
- },
70
- end: {
71
- line: 24,
72
- column: 7
73
- }
74
- },
75
- '6': {
76
- start: {
77
- line: 21,
78
- column: 6
79
- },
80
- end: {
81
- line: 23,
82
- column: 7
83
- }
84
- },
85
- '7': {
86
- start: {
87
- line: 22,
88
- column: 8
89
- },
90
- end: {
91
- line: 22,
92
- column: 37
93
- }
94
- },
95
- '8': {
96
- start: {
97
- line: 27,
98
- column: 2
99
- },
100
- end: {
101
- line: 27,
102
- column: 17
103
- }
104
- }
105
- },
106
- fnMap: {
107
- '0': {
108
- name: '(anonymous_0)',
109
- decl: {
110
- start: {
111
- line: 10,
112
- column: 15
113
- },
114
- end: {
115
- line: 10,
116
- column: 16
117
- }
118
- },
119
- loc: {
120
- start: {
121
- line: 10,
122
- column: 25
123
- },
124
- end: {
125
- line: 28,
126
- column: 1
127
- }
128
- }
129
- },
130
- '1': {
131
- name: '(anonymous_1)',
132
- decl: {
133
- start: {
134
- line: 17,
135
- column: 18
136
- },
137
- end: {
138
- line: 17,
139
- column: 19
140
- }
141
- },
142
- loc: {
143
- start: {
144
- line: 17,
145
- column: 27
146
- },
147
- end: {
148
- line: 25,
149
- column: 3
150
- }
151
- }
152
- },
153
- '2': {
154
- name: '(anonymous_2)',
155
- decl: {
156
- start: {
157
- line: 20,
158
- column: 32
159
- },
160
- end: {
161
- line: 20,
162
- column: 33
163
- }
164
- },
165
- loc: {
166
- start: {
167
- line: 20,
168
- column: 56
169
- },
170
- end: {
171
- line: 24,
172
- column: 5
173
- }
174
- }
175
- }
176
- },
177
- branchMap: {
178
- '0': {
179
- loc: {
180
- start: {
181
- line: 11,
182
- column: 2
183
- },
184
- end: {
185
- line: 13,
186
- column: 3
187
- }
188
- },
189
- type: 'if',
190
- locations: [{
191
- start: {
192
- line: 11,
193
- column: 2
194
- },
195
- end: {
196
- line: 13,
197
- column: 3
198
- }
199
- }, {
200
- start: {
201
- line: 11,
202
- column: 2
203
- },
204
- end: {
205
- line: 13,
206
- column: 3
207
- }
208
- }]
209
- },
210
- '1': {
211
- loc: {
212
- start: {
213
- line: 21,
214
- column: 6
215
- },
216
- end: {
217
- line: 23,
218
- column: 7
219
- }
220
- },
221
- type: 'if',
222
- locations: [{
223
- start: {
224
- line: 21,
225
- column: 6
226
- },
227
- end: {
228
- line: 23,
229
- column: 7
230
- }
231
- }, {
232
- start: {
233
- line: 21,
234
- column: 6
235
- },
236
- end: {
237
- line: 23,
238
- column: 7
239
- }
240
- }]
241
- }
242
- },
243
- s: {
244
- '0': 0,
245
- '1': 0,
246
- '2': 0,
247
- '3': 0,
248
- '4': 0,
249
- '5': 0,
250
- '6': 0,
251
- '7': 0,
252
- '8': 0
253
- },
254
- f: {
255
- '0': 0,
256
- '1': 0,
257
- '2': 0
258
- },
259
- b: {
260
- '0': [0, 0],
261
- '1': [0, 0]
262
- }
263
- },
264
- coverage = global[gcv] || (global[gcv] = {});
265
-
266
- if (coverage[path] && coverage[path].hash === hash) {
267
- return coverage[path];
268
- }
269
-
270
- coverageData.hash = hash;
271
- return coverage[path] = coverageData;
272
- }();
273
-
274
- var _lodash = require('lodash');
275
-
276
- var _lodash2 = _interopRequireDefault(_lodash);
277
-
278
7
  var _calculateCellWidthIndex = require('./calculateCellWidthIndex');
279
8
 
280
9
  var _calculateCellWidthIndex2 = _interopRequireDefault(_calculateCellWidthIndex);
@@ -288,44 +17,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
288
17
  * @returns {number[]}
289
18
  */
290
19
  exports.default = rows => {
291
- ++cov_qyqm9cd68.f[0];
292
- ++cov_qyqm9cd68.s[0];
293
-
294
20
  if (!rows[0]) {
295
- ++cov_qyqm9cd68.b[0][0];
296
- ++cov_qyqm9cd68.s[1];
297
-
298
21
  throw new Error('Dataset must have at least one row.');
299
- } else {
300
- ++cov_qyqm9cd68.b[0][1];
301
22
  }
302
23
 
303
- const columns = (++cov_qyqm9cd68.s[2], _lodash2.default.fill(Array(rows[0].length), 0));
304
-
305
- ++cov_qyqm9cd68.s[3];
306
- _lodash2.default.forEach(rows, row => {
307
- ++cov_qyqm9cd68.f[1];
24
+ const columns = Array(rows[0].length).fill(0);
308
25
 
309
- const columnWidthIndex = (++cov_qyqm9cd68.s[4], (0, _calculateCellWidthIndex2.default)(row));
310
-
311
- ++cov_qyqm9cd68.s[5];
312
- _lodash2.default.forEach(columnWidthIndex, (valueWidth, index0) => {
313
- ++cov_qyqm9cd68.f[2];
314
- ++cov_qyqm9cd68.s[6];
26
+ rows.forEach(row => {
27
+ const columnWidthIndex = (0, _calculateCellWidthIndex2.default)(row);
315
28
 
29
+ columnWidthIndex.forEach((valueWidth, index0) => {
316
30
  if (columns[index0] < valueWidth) {
317
- ++cov_qyqm9cd68.b[1][0];
318
- ++cov_qyqm9cd68.s[7];
319
-
320
31
  columns[index0] = valueWidth;
321
- } else {
322
- ++cov_qyqm9cd68.b[1][1];
323
32
  }
324
33
  });
325
34
  });
326
35
 
327
- ++cov_qyqm9cd68.s[8];
328
36
  return columns;
329
- };
330
-
331
- module.exports = exports['default'];
37
+ };