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,321 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var cov_9n6q52jtc = function () {
8
- var path = '/Users/gajuskuizinas/Documents/dev/gajus/table/src/mapDataUsingRowHeightIndex.js',
9
- hash = 'ef60a93a63cc52a2b2024b7c01e8fc35b8ef865f',
10
- global = new Function('return this')(),
11
- gcv = '__coverage__',
12
- coverageData = {
13
- path: '/Users/gajuskuizinas/Documents/dev/gajus/table/src/mapDataUsingRowHeightIndex.js',
14
- statementMap: {
15
- '0': {
16
- start: {
17
- line: 12,
18
- column: 21
19
- },
20
- end: {
21
- line: 12,
22
- column: 43
23
- }
24
- },
25
- '1': {
26
- start: {
27
- line: 14,
28
- column: 21
29
- },
30
- end: {
31
- line: 38,
32
- column: 4
33
- }
34
- },
35
- '2': {
36
- start: {
37
- line: 15,
38
- column: 22
39
- },
40
- end: {
41
- line: 17,
42
- column: 6
43
- }
44
- },
45
- '3': {
46
- start: {
47
- line: 16,
48
- column: 6
49
- },
50
- end: {
51
- line: 16,
52
- column: 43
53
- }
54
- },
55
- '4': {
56
- start: {
57
- line: 23,
58
- column: 4
59
- },
60
- end: {
61
- line: 35,
62
- column: 7
63
- }
64
- },
65
- '5': {
66
- start: {
67
- line: 26,
68
- column: 6
69
- },
70
- end: {
71
- line: 30,
72
- column: 7
73
- }
74
- },
75
- '6': {
76
- start: {
77
- line: 27,
78
- column: 8
79
- },
80
- end: {
81
- line: 27,
82
- column: 69
83
- }
84
- },
85
- '7': {
86
- start: {
87
- line: 29,
88
- column: 8
89
- },
90
- end: {
91
- line: 29,
92
- column: 71
93
- }
94
- },
95
- '8': {
96
- start: {
97
- line: 32,
98
- column: 6
99
- },
100
- end: {
101
- line: 34,
102
- column: 9
103
- }
104
- },
105
- '9': {
106
- start: {
107
- line: 33,
108
- column: 8
109
- },
110
- end: {
111
- line: 33,
112
- column: 41
113
- }
114
- },
115
- '10': {
116
- start: {
117
- line: 37,
118
- column: 4
119
- },
120
- end: {
121
- line: 37,
122
- column: 21
123
- }
124
- },
125
- '11': {
126
- start: {
127
- line: 40,
128
- column: 2
129
- },
130
- end: {
131
- line: 40,
132
- column: 31
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: 57
153
- },
154
- end: {
155
- line: 41,
156
- column: 1
157
- }
158
- }
159
- },
160
- '1': {
161
- name: '(anonymous_1)',
162
- decl: {
163
- start: {
164
- line: 14,
165
- column: 41
166
- },
167
- end: {
168
- line: 14,
169
- column: 42
170
- }
171
- },
172
- loc: {
173
- start: {
174
- line: 14,
175
- column: 60
176
- },
177
- end: {
178
- line: 38,
179
- column: 3
180
- }
181
- }
182
- },
183
- '2': {
184
- name: '(anonymous_2)',
185
- decl: {
186
- start: {
187
- line: 15,
188
- column: 54
189
- },
190
- end: {
191
- line: 15,
192
- column: 55
193
- }
194
- },
195
- loc: {
196
- start: {
197
- line: 15,
198
- column: 60
199
- },
200
- end: {
201
- line: 17,
202
- column: 5
203
- }
204
- }
205
- },
206
- '3': {
207
- name: '(anonymous_3)',
208
- decl: {
209
- start: {
210
- line: 23,
211
- column: 21
212
- },
213
- end: {
214
- line: 23,
215
- column: 22
216
- }
217
- },
218
- loc: {
219
- start: {
220
- line: 23,
221
- column: 40
222
- },
223
- end: {
224
- line: 35,
225
- column: 5
226
- }
227
- }
228
- },
229
- '4': {
230
- name: '(anonymous_4)',
231
- decl: {
232
- start: {
233
- line: 32,
234
- column: 30
235
- },
236
- end: {
237
- line: 32,
238
- column: 31
239
- }
240
- },
241
- loc: {
242
- start: {
243
- line: 32,
244
- column: 48
245
- },
246
- end: {
247
- line: 34,
248
- column: 7
249
- }
250
- }
251
- }
252
- },
253
- branchMap: {
254
- '0': {
255
- loc: {
256
- start: {
257
- line: 26,
258
- column: 6
259
- },
260
- end: {
261
- line: 30,
262
- column: 7
263
- }
264
- },
265
- type: 'if',
266
- locations: [{
267
- start: {
268
- line: 26,
269
- column: 6
270
- },
271
- end: {
272
- line: 30,
273
- column: 7
274
- }
275
- }, {
276
- start: {
277
- line: 26,
278
- column: 6
279
- },
280
- end: {
281
- line: 30,
282
- column: 7
283
- }
284
- }]
285
- }
286
- },
287
- s: {
288
- '0': 0,
289
- '1': 0,
290
- '2': 0,
291
- '3': 0,
292
- '4': 0,
293
- '5': 0,
294
- '6': 0,
295
- '7': 0,
296
- '8': 0,
297
- '9': 0,
298
- '10': 0,
299
- '11': 0
300
- },
301
- f: {
302
- '0': 0,
303
- '1': 0,
304
- '2': 0,
305
- '3': 0,
306
- '4': 0
307
- },
308
- b: {
309
- '0': [0, 0]
310
- }
311
- },
312
- coverage = global[gcv] || (global[gcv] = {});
313
-
314
- if (coverage[path] && coverage[path].hash === hash) {
315
- return coverage[path];
316
- }
317
-
318
- coverageData.hash = hash;
319
- return coverage[path] = coverageData;
320
- }();
321
-
322
7
  var _lodash = require('lodash');
323
8
 
324
9
  var _lodash2 = _interopRequireDefault(_lodash);
@@ -340,58 +25,33 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
340
25
  * @returns {Array}
341
26
  */
342
27
  exports.default = (unmappedRows, rowHeightIndex, config) => {
343
- ++cov_9n6q52jtc.f[0];
344
-
345
- const tableWidth = (++cov_9n6q52jtc.s[0], unmappedRows[0].length);
346
-
347
- const mappedRows = (++cov_9n6q52jtc.s[1], _lodash2.default.map(unmappedRows, (cells, index0) => {
348
- ++cov_9n6q52jtc.f[1];
28
+ const tableWidth = unmappedRows[0].length;
349
29
 
350
- const rowHeight = (++cov_9n6q52jtc.s[2], _lodash2.default.times(rowHeightIndex[index0], () => {
351
- ++cov_9n6q52jtc.f[2];
352
- ++cov_9n6q52jtc.s[3];
353
-
354
- return _lodash2.default.fill(Array(tableWidth), '');
355
- }));
30
+ const mappedRows = unmappedRows.map((cells, index0) => {
31
+ const rowHeight = _lodash2.default.times(rowHeightIndex[index0], () => {
32
+ return Array(tableWidth).fill('');
33
+ });
356
34
 
357
35
  // rowHeight
358
36
  // [{row index within rowSaw; index2}]
359
37
  // [{cell index within a virtual row; index1}]
360
38
 
361
- ++cov_9n6q52jtc.s[4];
362
- _lodash2.default.forEach(cells, (value, index1) => {
363
- ++cov_9n6q52jtc.f[3];
364
-
39
+ cells.forEach((value, index1) => {
365
40
  let chunkedValue;
366
41
 
367
- ++cov_9n6q52jtc.s[5];
368
42
  if (config.columns[index1].wrapWord) {
369
- ++cov_9n6q52jtc.b[0][0];
370
- ++cov_9n6q52jtc.s[6];
371
-
372
43
  chunkedValue = (0, _wrapWord2.default)(value, config.columns[index1].width);
373
44
  } else {
374
- ++cov_9n6q52jtc.b[0][1];
375
- ++cov_9n6q52jtc.s[7];
376
-
377
45
  chunkedValue = (0, _wrapString2.default)(value, config.columns[index1].width);
378
46
  }
379
47
 
380
- ++cov_9n6q52jtc.s[8];
381
- _lodash2.default.forEach(chunkedValue, (part, index2) => {
382
- ++cov_9n6q52jtc.f[4];
383
- ++cov_9n6q52jtc.s[9];
384
-
48
+ chunkedValue.forEach((part, index2) => {
385
49
  rowHeight[index2][index1] = part;
386
50
  });
387
51
  });
388
52
 
389
- ++cov_9n6q52jtc.s[10];
390
53
  return rowHeight;
391
- }));
54
+ });
392
55
 
393
- ++cov_9n6q52jtc.s[11];
394
56
  return _lodash2.default.flatten(mappedRows);
395
- };
396
-
397
- module.exports = exports['default'];
57
+ };
@@ -4,178 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var cov_twrxa7qlr = function () {
8
- var path = '/Users/gajuskuizinas/Documents/dev/gajus/table/src/padTableData.js',
9
- hash = '6e7c959e85570169d58cc4f337d2b17a58cea753',
10
- global = new Function('return this')(),
11
- gcv = '__coverage__',
12
- coverageData = {
13
- path: '/Users/gajuskuizinas/Documents/dev/gajus/table/src/padTableData.js',
14
- statementMap: {
15
- '0': {
16
- start: {
17
- line: 9,
18
- column: 2
19
- },
20
- end: {
21
- line: 15,
22
- column: 5
23
- }
24
- },
25
- '1': {
26
- start: {
27
- line: 10,
28
- column: 4
29
- },
30
- end: {
31
- line: 14,
32
- column: 7
33
- }
34
- },
35
- '2': {
36
- start: {
37
- line: 11,
38
- column: 21
39
- },
40
- end: {
41
- line: 11,
42
- column: 43
43
- }
44
- },
45
- '3': {
46
- start: {
47
- line: 13,
48
- column: 6
49
- },
50
- end: {
51
- line: 13,
52
- column: 92
53
- }
54
- }
55
- },
56
- fnMap: {
57
- '0': {
58
- name: '(anonymous_0)',
59
- decl: {
60
- start: {
61
- line: 8,
62
- column: 15
63
- },
64
- end: {
65
- line: 8,
66
- column: 16
67
- }
68
- },
69
- loc: {
70
- start: {
71
- line: 8,
72
- column: 33
73
- },
74
- end: {
75
- line: 16,
76
- column: 1
77
- }
78
- }
79
- },
80
- '1': {
81
- name: '(anonymous_1)',
82
- decl: {
83
- start: {
84
- line: 9,
85
- column: 21
86
- },
87
- end: {
88
- line: 9,
89
- column: 22
90
- }
91
- },
92
- loc: {
93
- start: {
94
- line: 9,
95
- column: 32
96
- },
97
- end: {
98
- line: 15,
99
- column: 3
100
- }
101
- }
102
- },
103
- '2': {
104
- name: '(anonymous_2)',
105
- decl: {
106
- start: {
107
- line: 10,
108
- column: 24
109
- },
110
- end: {
111
- line: 10,
112
- column: 25
113
- }
114
- },
115
- loc: {
116
- start: {
117
- line: 10,
118
- column: 43
119
- },
120
- end: {
121
- line: 14,
122
- column: 5
123
- }
124
- }
125
- }
126
- },
127
- branchMap: {},
128
- s: {
129
- '0': 0,
130
- '1': 0,
131
- '2': 0,
132
- '3': 0
133
- },
134
- f: {
135
- '0': 0,
136
- '1': 0,
137
- '2': 0
138
- },
139
- b: {}
140
- },
141
- coverage = global[gcv] || (global[gcv] = {});
142
-
143
- if (coverage[path] && coverage[path].hash === hash) {
144
- return coverage[path];
145
- }
146
-
147
- coverageData.hash = hash;
148
- return coverage[path] = coverageData;
149
- }();
150
-
151
- var _lodash = require('lodash');
152
-
153
- var _lodash2 = _interopRequireDefault(_lodash);
154
-
155
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
156
-
157
7
  /**
158
8
  * @param {table~row[]} rows
159
9
  * @param {Object} config
160
10
  * @returns {table~row[]}
161
11
  */
162
12
  exports.default = (rows, config) => {
163
- ++cov_twrxa7qlr.f[0];
164
- ++cov_twrxa7qlr.s[0];
165
-
166
- return _lodash2.default.map(rows, cells => {
167
- ++cov_twrxa7qlr.f[1];
168
- ++cov_twrxa7qlr.s[1];
169
-
170
- return _lodash2.default.map(cells, (value, index1) => {
171
- ++cov_twrxa7qlr.f[2];
13
+ return rows.map(cells => {
14
+ return cells.map((value, index1) => {
15
+ const column = config.columns[index1];
172
16
 
173
- const column = (++cov_twrxa7qlr.s[2], config.columns[index1]);
174
-
175
- ++cov_twrxa7qlr.s[3];
176
- return _lodash2.default.repeat(' ', column.paddingLeft) + value + _lodash2.default.repeat(' ', column.paddingRight);
17
+ return ' '.repeat(column.paddingLeft) + value + ' '.repeat(column.paddingRight);
177
18
  });
178
19
  });
179
- };
180
-
181
- module.exports = exports['default'];
20
+ };
@@ -1,6 +1,6 @@
1
1
  {
2
- "id": "config.json",
3
- "$schema": "http://json-schema.org/draft-04/schema#",
2
+ "$id": "config.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
4
  "type": "object",
5
5
  "properties": {
6
6
  "border": {
@@ -1,6 +1,6 @@
1
1
  {
2
- "id": "streamConfig.json",
3
- "$schema": "http://json-schema.org/draft-04/schema#",
2
+ "$id": "streamConfig.json",
3
+ "$schema": "http://json-schema.org/draft-06/schema#",
4
4
  "type": "object",
5
5
  "properties": {
6
6
  "border": {
@@ -1,113 +1,9 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var cov_1g1o2zo2a1 = function () {
8
- var path = '/Users/gajuskuizinas/Documents/dev/gajus/table/src/stringifyTableData.js',
9
- hash = '259c356ed61ccc108a62d2707db6e7eccf7f6c78',
10
- global = new Function('return this')(),
11
- gcv = '__coverage__',
12
- coverageData = {
13
- path: '/Users/gajuskuizinas/Documents/dev/gajus/table/src/stringifyTableData.js',
14
- statementMap: {
15
- '0': {
16
- start: {
17
- line: 10,
18
- column: 2
19
- },
20
- end: {
21
- line: 12,
22
- column: 5
23
- }
24
- },
25
- '1': {
26
- start: {
27
- line: 11,
28
- column: 4
29
- },
30
- end: {
31
- line: 11,
32
- column: 32
33
- }
34
- }
35
- },
36
- fnMap: {
37
- '0': {
38
- name: '(anonymous_0)',
39
- decl: {
40
- start: {
41
- line: 9,
42
- column: 15
43
- },
44
- end: {
45
- line: 9,
46
- column: 16
47
- }
48
- },
49
- loc: {
50
- start: {
51
- line: 9,
52
- column: 25
53
- },
54
- end: {
55
- line: 13,
56
- column: 1
57
- }
58
- }
59
- },
60
- '1': {
61
- name: '(anonymous_1)',
62
- decl: {
63
- start: {
64
- line: 10,
65
- column: 21
66
- },
67
- end: {
68
- line: 10,
69
- column: 22
70
- }
71
- },
72
- loc: {
73
- start: {
74
- line: 10,
75
- column: 32
76
- },
77
- end: {
78
- line: 12,
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
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
110
-
111
7
  /**
112
8
  * Casts all cell values to a string.
113
9
  *
@@ -115,15 +11,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
115
11
  * @returns {table~row[]}
116
12
  */
117
13
  exports.default = rows => {
118
- ++cov_1g1o2zo2a1.f[0];
119
- ++cov_1g1o2zo2a1.s[0];
120
-
121
- return _lodash2.default.map(rows, cells => {
122
- ++cov_1g1o2zo2a1.f[1];
123
- ++cov_1g1o2zo2a1.s[1];
124
-
125
- return _lodash2.default.map(cells, String);
14
+ return rows.map(cells => {
15
+ return cells.map(String);
126
16
  });
127
- };
128
-
129
- module.exports = exports['default'];
17
+ };