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,211 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var cov_2pktuqk92z = function () {
8
- var path = '/Users/gajuskuizinas/Documents/dev/gajus/table/src/alignTableData.js',
9
- hash = '913eacde8fc43c298d627dea94c57331a147b681',
10
- global = new Function('return this')(),
11
- gcv = '__coverage__',
12
- coverageData = {
13
- path: '/Users/gajuskuizinas/Documents/dev/gajus/table/src/alignTableData.js',
14
- statementMap: {
15
- '0': {
16
- start: {
17
- line: 11,
18
- column: 2
19
- },
20
- end: {
21
- line: 21,
22
- column: 5
23
- }
24
- },
25
- '1': {
26
- start: {
27
- line: 12,
28
- column: 4
29
- },
30
- end: {
31
- line: 20,
32
- column: 7
33
- }
34
- },
35
- '2': {
36
- start: {
37
- line: 13,
38
- column: 21
39
- },
40
- end: {
41
- line: 13,
42
- column: 43
43
- }
44
- },
45
- '3': {
46
- start: {
47
- line: 15,
48
- column: 6
49
- },
50
- end: {
51
- line: 19,
52
- column: 7
53
- }
54
- },
55
- '4': {
56
- start: {
57
- line: 16,
58
- column: 8
59
- },
60
- end: {
61
- line: 16,
62
- column: 21
63
- }
64
- },
65
- '5': {
66
- start: {
67
- line: 18,
68
- column: 8
69
- },
70
- end: {
71
- line: 18,
72
- column: 66
73
- }
74
- }
75
- },
76
- fnMap: {
77
- '0': {
78
- name: '(anonymous_0)',
79
- decl: {
80
- start: {
81
- line: 10,
82
- column: 15
83
- },
84
- end: {
85
- line: 10,
86
- column: 16
87
- }
88
- },
89
- loc: {
90
- start: {
91
- line: 10,
92
- column: 33
93
- },
94
- end: {
95
- line: 22,
96
- column: 1
97
- }
98
- }
99
- },
100
- '1': {
101
- name: '(anonymous_1)',
102
- decl: {
103
- start: {
104
- line: 11,
105
- column: 21
106
- },
107
- end: {
108
- line: 11,
109
- column: 22
110
- }
111
- },
112
- loc: {
113
- start: {
114
- line: 11,
115
- column: 32
116
- },
117
- end: {
118
- line: 21,
119
- column: 3
120
- }
121
- }
122
- },
123
- '2': {
124
- name: '(anonymous_2)',
125
- decl: {
126
- start: {
127
- line: 12,
128
- column: 24
129
- },
130
- end: {
131
- line: 12,
132
- column: 25
133
- }
134
- },
135
- loc: {
136
- start: {
137
- line: 12,
138
- column: 43
139
- },
140
- end: {
141
- line: 20,
142
- column: 5
143
- }
144
- }
145
- }
146
- },
147
- branchMap: {
148
- '0': {
149
- loc: {
150
- start: {
151
- line: 15,
152
- column: 6
153
- },
154
- end: {
155
- line: 19,
156
- column: 7
157
- }
158
- },
159
- type: 'if',
160
- locations: [{
161
- start: {
162
- line: 15,
163
- column: 6
164
- },
165
- end: {
166
- line: 19,
167
- column: 7
168
- }
169
- }, {
170
- start: {
171
- line: 15,
172
- column: 6
173
- },
174
- end: {
175
- line: 19,
176
- column: 7
177
- }
178
- }]
179
- }
180
- },
181
- s: {
182
- '0': 0,
183
- '1': 0,
184
- '2': 0,
185
- '3': 0,
186
- '4': 0,
187
- '5': 0
188
- },
189
- f: {
190
- '0': 0,
191
- '1': 0,
192
- '2': 0
193
- },
194
- b: {
195
- '0': [0, 0]
196
- }
197
- },
198
- coverage = global[gcv] || (global[gcv] = {});
199
-
200
- if (coverage[path] && coverage[path].hash === hash) {
201
- return coverage[path];
202
- }
203
-
204
- coverageData.hash = hash;
205
- return coverage[path] = coverageData;
206
- }();
207
-
208
- var _lodash = require('lodash');
209
-
210
- var _lodash2 = _interopRequireDefault(_lodash);
211
-
212
7
  var _stringWidth = require('string-width');
213
8
 
214
9
  var _stringWidth2 = _interopRequireDefault(_stringWidth);
@@ -225,32 +20,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
225
20
  * @returns {table~row[]}
226
21
  */
227
22
  exports.default = (rows, config) => {
228
- ++cov_2pktuqk92z.f[0];
229
- ++cov_2pktuqk92z.s[0];
230
-
231
- return _lodash2.default.map(rows, cells => {
232
- ++cov_2pktuqk92z.f[1];
233
- ++cov_2pktuqk92z.s[1];
234
-
235
- return _lodash2.default.map(cells, (value, index1) => {
236
- ++cov_2pktuqk92z.f[2];
237
-
238
- const column = (++cov_2pktuqk92z.s[2], config.columns[index1]);
23
+ return rows.map(cells => {
24
+ return cells.map((value, index1) => {
25
+ const column = config.columns[index1];
239
26
 
240
- ++cov_2pktuqk92z.s[3];
241
27
  if ((0, _stringWidth2.default)(value) === column.width) {
242
- ++cov_2pktuqk92z.b[0][0];
243
- ++cov_2pktuqk92z.s[4];
244
-
245
28
  return value;
246
29
  } else {
247
- ++cov_2pktuqk92z.b[0][1];
248
- ++cov_2pktuqk92z.s[5];
249
-
250
30
  return (0, _alignString2.default)(value, column.width, column.alignment);
251
31
  }
252
32
  });
253
33
  });
254
- };
255
-
256
- module.exports = exports['default'];
34
+ };
@@ -4,315 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var cov_o4tfba3lv = function () {
8
- var path = '/Users/gajuskuizinas/Documents/dev/gajus/table/src/calculateCellHeight.js',
9
- hash = 'a65906da9699d691d072da9a76fc1ac18702e1f5',
10
- global = new Function('return this')(),
11
- gcv = '__coverage__',
12
- coverageData = {
13
- path: '/Users/gajuskuizinas/Documents/dev/gajus/table/src/calculateCellHeight.js',
14
- statementMap: {
15
- '0': {
16
- start: {
17
- line: 12,
18
- column: 2
19
- },
20
- end: {
21
- line: 14,
22
- column: 3
23
- }
24
- },
25
- '1': {
26
- start: {
27
- line: 13,
28
- column: 4
29
- },
30
- end: {
31
- line: 13,
32
- column: 47
33
- }
34
- },
35
- '2': {
36
- start: {
37
- line: 16,
38
- column: 2
39
- },
40
- end: {
41
- line: 18,
42
- column: 3
43
- }
44
- },
45
- '3': {
46
- start: {
47
- line: 17,
48
- column: 4
49
- },
50
- end: {
51
- line: 17,
52
- column: 56
53
- }
54
- },
55
- '4': {
56
- start: {
57
- line: 20,
58
- column: 2
59
- },
60
- end: {
61
- line: 22,
62
- column: 3
63
- }
64
- },
65
- '5': {
66
- start: {
67
- line: 21,
68
- column: 4
69
- },
70
- end: {
71
- line: 21,
72
- column: 60
73
- }
74
- },
75
- '6': {
76
- start: {
77
- line: 24,
78
- column: 2
79
- },
80
- end: {
81
- line: 26,
82
- column: 3
83
- }
84
- },
85
- '7': {
86
- start: {
87
- line: 25,
88
- column: 4
89
- },
90
- end: {
91
- line: 25,
92
- column: 47
93
- }
94
- },
95
- '8': {
96
- start: {
97
- line: 28,
98
- column: 2
99
- },
100
- end: {
101
- line: 28,
102
- column: 50
103
- }
104
- }
105
- },
106
- fnMap: {
107
- '0': {
108
- name: '(anonymous_0)',
109
- decl: {
110
- start: {
111
- line: 11,
112
- column: 15
113
- },
114
- end: {
115
- line: 11,
116
- column: 16
117
- }
118
- },
119
- loc: {
120
- start: {
121
- line: 11,
122
- column: 60
123
- },
124
- end: {
125
- line: 29,
126
- column: 1
127
- }
128
- }
129
- }
130
- },
131
- branchMap: {
132
- '0': {
133
- loc: {
134
- start: {
135
- line: 11,
136
- column: 36
137
- },
138
- end: {
139
- line: 11,
140
- column: 55
141
- }
142
- },
143
- type: 'default-arg',
144
- locations: [{
145
- start: {
146
- line: 11,
147
- column: 50
148
- },
149
- end: {
150
- line: 11,
151
- column: 55
152
- }
153
- }]
154
- },
155
- '1': {
156
- loc: {
157
- start: {
158
- line: 12,
159
- column: 2
160
- },
161
- end: {
162
- line: 14,
163
- column: 3
164
- }
165
- },
166
- type: 'if',
167
- locations: [{
168
- start: {
169
- line: 12,
170
- column: 2
171
- },
172
- end: {
173
- line: 14,
174
- column: 3
175
- }
176
- }, {
177
- start: {
178
- line: 12,
179
- column: 2
180
- },
181
- end: {
182
- line: 14,
183
- column: 3
184
- }
185
- }]
186
- },
187
- '2': {
188
- loc: {
189
- start: {
190
- line: 16,
191
- column: 2
192
- },
193
- end: {
194
- line: 18,
195
- column: 3
196
- }
197
- },
198
- type: 'if',
199
- locations: [{
200
- start: {
201
- line: 16,
202
- column: 2
203
- },
204
- end: {
205
- line: 18,
206
- column: 3
207
- }
208
- }, {
209
- start: {
210
- line: 16,
211
- column: 2
212
- },
213
- end: {
214
- line: 18,
215
- column: 3
216
- }
217
- }]
218
- },
219
- '3': {
220
- loc: {
221
- start: {
222
- line: 20,
223
- column: 2
224
- },
225
- end: {
226
- line: 22,
227
- column: 3
228
- }
229
- },
230
- type: 'if',
231
- locations: [{
232
- start: {
233
- line: 20,
234
- column: 2
235
- },
236
- end: {
237
- line: 22,
238
- column: 3
239
- }
240
- }, {
241
- start: {
242
- line: 20,
243
- column: 2
244
- },
245
- end: {
246
- line: 22,
247
- column: 3
248
- }
249
- }]
250
- },
251
- '4': {
252
- loc: {
253
- start: {
254
- line: 24,
255
- column: 2
256
- },
257
- end: {
258
- line: 26,
259
- column: 3
260
- }
261
- },
262
- type: 'if',
263
- locations: [{
264
- start: {
265
- line: 24,
266
- column: 2
267
- },
268
- end: {
269
- line: 26,
270
- column: 3
271
- }
272
- }, {
273
- start: {
274
- line: 24,
275
- column: 2
276
- },
277
- end: {
278
- line: 26,
279
- column: 3
280
- }
281
- }]
282
- }
283
- },
284
- s: {
285
- '0': 0,
286
- '1': 0,
287
- '2': 0,
288
- '3': 0,
289
- '4': 0,
290
- '5': 0,
291
- '6': 0,
292
- '7': 0,
293
- '8': 0
294
- },
295
- f: {
296
- '0': 0
297
- },
298
- b: {
299
- '0': [0],
300
- '1': [0, 0],
301
- '2': [0, 0],
302
- '3': [0, 0],
303
- '4': [0, 0]
304
- }
305
- },
306
- coverage = global[gcv] || (global[gcv] = {});
307
-
308
- if (coverage[path] && coverage[path].hash === hash) {
309
- return coverage[path];
310
- }
311
-
312
- coverageData.hash = hash;
313
- return coverage[path] = coverageData;
314
- }();
315
-
316
7
  var _lodash = require('lodash');
317
8
 
318
9
  var _lodash2 = _interopRequireDefault(_lodash);
@@ -334,51 +25,23 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
334
25
  * @returns {number}
335
26
  */
336
27
  exports.default = function (value, columnWidth) {
337
- let useWrapWord = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (++cov_o4tfba3lv.b[0][0], false);
338
- ++cov_o4tfba3lv.f[0];
339
- ++cov_o4tfba3lv.s[0];
28
+ let useWrapWord = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
340
29
 
341
30
  if (!_lodash2.default.isString(value)) {
342
- ++cov_o4tfba3lv.b[1][0];
343
- ++cov_o4tfba3lv.s[1];
344
-
345
- throw new Error('Value must be a string.');
346
- } else {
347
- ++cov_o4tfba3lv.b[1][1];
31
+ throw new TypeError('Value must be a string.');
348
32
  }
349
33
 
350
- ++cov_o4tfba3lv.s[2];
351
- if (!_lodash2.default.isInteger(columnWidth)) {
352
- ++cov_o4tfba3lv.b[2][0];
353
- ++cov_o4tfba3lv.s[3];
354
-
355
- throw new Error('Column width must be an integer.');
356
- } else {
357
- ++cov_o4tfba3lv.b[2][1];
34
+ if (!Number.isInteger(columnWidth)) {
35
+ throw new TypeError('Column width must be an integer.');
358
36
  }
359
37
 
360
- ++cov_o4tfba3lv.s[4];
361
38
  if (columnWidth < 1) {
362
- ++cov_o4tfba3lv.b[3][0];
363
- ++cov_o4tfba3lv.s[5];
364
-
365
39
  throw new Error('Column width must be greater than 0.');
366
- } else {
367
- ++cov_o4tfba3lv.b[3][1];
368
40
  }
369
41
 
370
- ++cov_o4tfba3lv.s[6];
371
42
  if (useWrapWord) {
372
- ++cov_o4tfba3lv.b[4][0];
373
- ++cov_o4tfba3lv.s[7];
374
-
375
43
  return (0, _wrapWord2.default)(value, columnWidth).length;
376
- } else {
377
- ++cov_o4tfba3lv.b[4][1];
378
44
  }
379
45
 
380
- ++cov_o4tfba3lv.s[8];
381
- return _lodash2.default.ceil((0, _stringWidth2.default)(value) / columnWidth);
382
- };
383
-
384
- module.exports = exports['default'];
46
+ return Math.ceil((0, _stringWidth2.default)(value) / columnWidth);
47
+ };