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
package/dist/table.js CHANGED
@@ -4,194 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var cov_1y0c093qbd = function () {
8
- var path = '/Users/gajuskuizinas/Documents/dev/gajus/table/src/table.js',
9
- hash = 'd4162e54a4a463a5103e2932efcc4187503c2876',
10
- global = new Function('return this')(),
11
- gcv = '__coverage__',
12
- coverageData = {
13
- path: '/Users/gajuskuizinas/Documents/dev/gajus/table/src/table.js',
14
- statementMap: {
15
- '0': {
16
- start: {
17
- line: 77,
18
- column: 2
19
- },
20
- end: {
21
- line: 77,
22
- column: 26
23
- }
24
- },
25
- '1': {
26
- start: {
27
- line: 79,
28
- column: 2
29
- },
30
- end: {
31
- line: 79,
32
- column: 34
33
- }
34
- },
35
- '2': {
36
- start: {
37
- line: 81,
38
- column: 17
39
- },
40
- end: {
41
- line: 81,
42
- column: 45
43
- }
44
- },
45
- '3': {
46
- start: {
47
- line: 83,
48
- column: 2
49
- },
50
- end: {
51
- line: 83,
52
- column: 41
53
- }
54
- },
55
- '4': {
56
- start: {
57
- line: 85,
58
- column: 25
59
- },
60
- end: {
61
- line: 85,
62
- column: 62
63
- }
64
- },
65
- '5': {
66
- start: {
67
- line: 87,
68
- column: 2
69
- },
70
- end: {
71
- line: 87,
72
- column: 66
73
- }
74
- },
75
- '6': {
76
- start: {
77
- line: 88,
78
- column: 2
79
- },
80
- end: {
81
- line: 88,
82
- column: 38
83
- }
84
- },
85
- '7': {
86
- start: {
87
- line: 89,
88
- column: 2
89
- },
90
- end: {
91
- line: 89,
92
- column: 36
93
- }
94
- },
95
- '8': {
96
- start: {
97
- line: 91,
98
- column: 25
99
- },
100
- end: {
101
- line: 91,
102
- column: 57
103
- }
104
- },
105
- '9': {
106
- start: {
107
- line: 93,
108
- column: 2
109
- },
110
- end: {
111
- line: 93,
112
- column: 99
113
- }
114
- }
115
- },
116
- fnMap: {
117
- '0': {
118
- name: '(anonymous_0)',
119
- decl: {
120
- start: {
121
- line: 74,
122
- column: 15
123
- },
124
- end: {
125
- line: 74,
126
- column: 16
127
- }
128
- },
129
- loc: {
130
- start: {
131
- line: 74,
132
- column: 42
133
- },
134
- end: {
135
- line: 94,
136
- column: 1
137
- }
138
- }
139
- }
140
- },
141
- branchMap: {
142
- '0': {
143
- loc: {
144
- start: {
145
- line: 74,
146
- column: 22
147
- },
148
- end: {
149
- line: 74,
150
- column: 37
151
- }
152
- },
153
- type: 'default-arg',
154
- locations: [{
155
- start: {
156
- line: 74,
157
- column: 35
158
- },
159
- end: {
160
- line: 74,
161
- column: 37
162
- }
163
- }]
164
- }
165
- },
166
- s: {
167
- '0': 0,
168
- '1': 0,
169
- '2': 0,
170
- '3': 0,
171
- '4': 0,
172
- '5': 0,
173
- '6': 0,
174
- '7': 0,
175
- '8': 0,
176
- '9': 0
177
- },
178
- f: {
179
- '0': 0
180
- },
181
- b: {
182
- '0': [0]
183
- }
184
- },
185
- coverage = global[gcv] || (global[gcv] = {});
186
-
187
- if (coverage[path] && coverage[path].hash === hash) {
188
- return coverage[path];
189
- }
190
-
191
- coverageData.hash = hash;
192
- return coverage[path] = coverageData;
193
- }();
194
-
195
7
  var _drawTable = require('./drawTable');
196
8
 
197
9
  var _drawTable2 = _interopRequireDefault(_drawTable);
@@ -297,35 +109,25 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
297
109
  * @returns {string}
298
110
  */
299
111
  exports.default = function (data) {
300
- let userConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (++cov_1y0c093qbd.b[0][0], {});
301
- ++cov_1y0c093qbd.f[0];
112
+ let userConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
302
113
 
303
114
  let rows;
304
115
 
305
- ++cov_1y0c093qbd.s[0];
306
116
  (0, _validateTableData2.default)(data);
307
117
 
308
- ++cov_1y0c093qbd.s[1];
309
118
  rows = (0, _stringifyTableData2.default)(data);
310
119
 
311
- const config = (++cov_1y0c093qbd.s[2], (0, _makeConfig2.default)(rows, userConfig));
120
+ const config = (0, _makeConfig2.default)(rows, userConfig);
312
121
 
313
- ++cov_1y0c093qbd.s[3];
314
122
  rows = (0, _truncateTableData2.default)(data, config);
315
123
 
316
- const rowHeightIndex = (++cov_1y0c093qbd.s[4], (0, _calculateRowHeightIndex2.default)(rows, config));
124
+ const rowHeightIndex = (0, _calculateRowHeightIndex2.default)(rows, config);
317
125
 
318
- ++cov_1y0c093qbd.s[5];
319
126
  rows = (0, _mapDataUsingRowHeightIndex2.default)(rows, rowHeightIndex, config);
320
- ++cov_1y0c093qbd.s[6];
321
127
  rows = (0, _alignTableData2.default)(rows, config);
322
- ++cov_1y0c093qbd.s[7];
323
128
  rows = (0, _padTableData2.default)(rows, config);
324
129
 
325
- const cellWidthIndex = (++cov_1y0c093qbd.s[8], (0, _calculateCellWidthIndex2.default)(rows[0]));
130
+ const cellWidthIndex = (0, _calculateCellWidthIndex2.default)(rows[0]);
326
131
 
327
- ++cov_1y0c093qbd.s[9];
328
132
  return (0, _drawTable2.default)(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine);
329
- };
330
-
331
- module.exports = exports['default'];
133
+ };
@@ -4,139 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var cov_2ah9qi3g32 = function () {
8
- var path = '/Users/gajuskuizinas/Documents/dev/gajus/table/src/truncateTableData.js',
9
- hash = '206286e5f3c48d9bf4d4c90ecb0d671778434f3b',
10
- global = new Function('return this')(),
11
- gcv = '__coverage__',
12
- coverageData = {
13
- path: '/Users/gajuskuizinas/Documents/dev/gajus/table/src/truncateTableData.js',
14
- statementMap: {
15
- '0': {
16
- start: {
17
- line: 10,
18
- column: 2
19
- },
20
- end: {
21
- line: 16,
22
- column: 5
23
- }
24
- },
25
- '1': {
26
- start: {
27
- line: 11,
28
- column: 4
29
- },
30
- end: {
31
- line: 15,
32
- column: 7
33
- }
34
- },
35
- '2': {
36
- start: {
37
- line: 12,
38
- column: 6
39
- },
40
- end: {
41
- line: 14,
42
- column: 9
43
- }
44
- }
45
- },
46
- fnMap: {
47
- '0': {
48
- name: '(anonymous_0)',
49
- decl: {
50
- start: {
51
- line: 9,
52
- column: 15
53
- },
54
- end: {
55
- line: 9,
56
- column: 16
57
- }
58
- },
59
- loc: {
60
- start: {
61
- line: 9,
62
- column: 33
63
- },
64
- end: {
65
- line: 17,
66
- column: 1
67
- }
68
- }
69
- },
70
- '1': {
71
- name: '(anonymous_1)',
72
- decl: {
73
- start: {
74
- line: 10,
75
- column: 21
76
- },
77
- end: {
78
- line: 10,
79
- column: 22
80
- }
81
- },
82
- loc: {
83
- start: {
84
- line: 10,
85
- column: 32
86
- },
87
- end: {
88
- line: 16,
89
- column: 3
90
- }
91
- }
92
- },
93
- '2': {
94
- name: '(anonymous_2)',
95
- decl: {
96
- start: {
97
- line: 11,
98
- column: 24
99
- },
100
- end: {
101
- line: 11,
102
- column: 25
103
- }
104
- },
105
- loc: {
106
- start: {
107
- line: 11,
108
- column: 44
109
- },
110
- end: {
111
- line: 15,
112
- column: 5
113
- }
114
- }
115
- }
116
- },
117
- branchMap: {},
118
- s: {
119
- '0': 0,
120
- '1': 0,
121
- '2': 0
122
- },
123
- f: {
124
- '0': 0,
125
- '1': 0,
126
- '2': 0
127
- },
128
- b: {}
129
- },
130
- coverage = global[gcv] || (global[gcv] = {});
131
-
132
- if (coverage[path] && coverage[path].hash === hash) {
133
- return coverage[path];
134
- }
135
-
136
- coverageData.hash = hash;
137
- return coverage[path] = coverageData;
138
- }();
139
-
140
7
  var _lodash = require('lodash');
141
8
 
142
9
  var _lodash2 = _interopRequireDefault(_lodash);
@@ -150,22 +17,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
150
17
  * @returns {table~row[]}
151
18
  */
152
19
  exports.default = (rows, config) => {
153
- ++cov_2ah9qi3g32.f[0];
154
- ++cov_2ah9qi3g32.s[0];
155
-
156
- return _lodash2.default.map(rows, cells => {
157
- ++cov_2ah9qi3g32.f[1];
158
- ++cov_2ah9qi3g32.s[1];
159
-
160
- return _lodash2.default.map(cells, (content, index) => {
161
- ++cov_2ah9qi3g32.f[2];
162
- ++cov_2ah9qi3g32.s[2];
163
-
20
+ return rows.map(cells => {
21
+ return cells.map((content, index) => {
164
22
  return _lodash2.default.truncate(content, {
165
23
  length: config.columns[index].truncate
166
24
  });
167
25
  });
168
26
  });
169
- };
170
-
171
- module.exports = exports['default'];
27
+ };
@@ -243,7 +243,6 @@ var validate = (function() {
243
243
  'use strict';
244
244
  var vErrors = null;
245
245
  var errors = 0;
246
- if (rootData === undefined) rootData = data;
247
246
  if (typeof data !== "string") {
248
247
  var err = {
249
248
  keyword: 'type',
@@ -341,7 +340,6 @@ var validate = (function() {
341
340
  'use strict';
342
341
  var vErrors = null;
343
342
  var errors = 0;
344
- if (rootData === undefined) rootData = data;
345
343
  if ((data && typeof data === "object" && !Array.isArray(data))) {
346
344
  var errs__0 = errors;
347
345
  var valid1 = true;
@@ -366,6 +364,20 @@ var validate = (function() {
366
364
  var data1 = data.alignment;
367
365
  if (data1 !== undefined) {
368
366
  var errs_1 = errors;
367
+ if (typeof data1 !== "string") {
368
+ var err = {
369
+ keyword: 'type',
370
+ dataPath: (dataPath || '') + '.alignment',
371
+ schemaPath: '#/properties/alignment/type',
372
+ params: {
373
+ type: 'string'
374
+ },
375
+ message: 'should be string'
376
+ };
377
+ if (vErrors === null) vErrors = [err];
378
+ else vErrors.push(err);
379
+ errors++;
380
+ }
369
381
  var schema1 = validate.schema.properties.alignment.enum;
370
382
  var valid1;
371
383
  valid1 = false;
@@ -388,20 +400,6 @@ var validate = (function() {
388
400
  else vErrors.push(err);
389
401
  errors++;
390
402
  }
391
- if (typeof data1 !== "string") {
392
- var err = {
393
- keyword: 'type',
394
- dataPath: (dataPath || '') + '.alignment',
395
- schemaPath: '#/properties/alignment/type',
396
- params: {
397
- type: 'string'
398
- },
399
- message: 'should be string'
400
- };
401
- if (vErrors === null) vErrors = [err];
402
- else vErrors.push(err);
403
- errors++;
404
- }
405
403
  var valid1 = errors === errs_1;
406
404
  }
407
405
  if (data.width !== undefined) {
@@ -540,7 +538,7 @@ var validate = (function() {
540
538
  refVal4.errors = null;
541
539
  refVal[4] = refVal4;
542
540
  return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
543
- 'use strict';
541
+ 'use strict'; /*# sourceURL=config.json */
544
542
  var vErrors = null;
545
543
  var errors = 0;
546
544
  if (rootData === undefined) rootData = data;
@@ -596,7 +594,8 @@ var validate = (function() {
596
594
  var errs_1 = errors;
597
595
  var errs__1 = errors;
598
596
  var valid1;
599
- if (!(typeof data.drawHorizontalLine == "function")) {
597
+ valid1 = typeof data.drawHorizontalLine == "function";
598
+ if (!valid1) {
600
599
  if (errs__1 == errors) {
601
600
  var err = {
602
601
  keyword: 'typeof',
@@ -613,9 +612,7 @@ var validate = (function() {
613
612
  } else {
614
613
  for (var i1 = errs__1; i1 < errors; i1++) {
615
614
  var ruleErr1 = vErrors[i1];
616
- if (ruleErr1.dataPath === undefined) {
617
- ruleErr1.dataPath = (dataPath || '') + '.drawHorizontalLine';
618
- }
615
+ if (ruleErr1.dataPath === undefined) ruleErr1.dataPath = (dataPath || '') + '.drawHorizontalLine';
619
616
  if (ruleErr1.schemaPath === undefined) {
620
617
  ruleErr1.schemaPath = "#/properties/drawHorizontalLine/typeof";
621
618
  }
@@ -643,8 +640,8 @@ var validate = (function() {
643
640
  };
644
641
  })();
645
642
  validate.schema = {
646
- "id": "config.json",
647
- "$schema": "http://json-schema.org/draft-04/schema#",
643
+ "$id": "config.json",
644
+ "$schema": "http://json-schema.org/draft-06/schema#",
648
645
  "type": "object",
649
646
  "properties": {
650
647
  "border": {
@@ -243,7 +243,6 @@ var validate = (function() {
243
243
  'use strict';
244
244
  var vErrors = null;
245
245
  var errors = 0;
246
- if (rootData === undefined) rootData = data;
247
246
  if (typeof data !== "string") {
248
247
  var err = {
249
248
  keyword: 'type',
@@ -341,7 +340,6 @@ var validate = (function() {
341
340
  'use strict';
342
341
  var vErrors = null;
343
342
  var errors = 0;
344
- if (rootData === undefined) rootData = data;
345
343
  if ((data && typeof data === "object" && !Array.isArray(data))) {
346
344
  var errs__0 = errors;
347
345
  var valid1 = true;
@@ -366,6 +364,20 @@ var validate = (function() {
366
364
  var data1 = data.alignment;
367
365
  if (data1 !== undefined) {
368
366
  var errs_1 = errors;
367
+ if (typeof data1 !== "string") {
368
+ var err = {
369
+ keyword: 'type',
370
+ dataPath: (dataPath || '') + '.alignment',
371
+ schemaPath: '#/properties/alignment/type',
372
+ params: {
373
+ type: 'string'
374
+ },
375
+ message: 'should be string'
376
+ };
377
+ if (vErrors === null) vErrors = [err];
378
+ else vErrors.push(err);
379
+ errors++;
380
+ }
369
381
  var schema1 = validate.schema.properties.alignment.enum;
370
382
  var valid1;
371
383
  valid1 = false;
@@ -388,20 +400,6 @@ var validate = (function() {
388
400
  else vErrors.push(err);
389
401
  errors++;
390
402
  }
391
- if (typeof data1 !== "string") {
392
- var err = {
393
- keyword: 'type',
394
- dataPath: (dataPath || '') + '.alignment',
395
- schemaPath: '#/properties/alignment/type',
396
- params: {
397
- type: 'string'
398
- },
399
- message: 'should be string'
400
- };
401
- if (vErrors === null) vErrors = [err];
402
- else vErrors.push(err);
403
- errors++;
404
- }
405
403
  var valid1 = errors === errs_1;
406
404
  }
407
405
  if (data.width !== undefined) {
@@ -540,7 +538,7 @@ var validate = (function() {
540
538
  refVal4.errors = null;
541
539
  refVal[4] = refVal4;
542
540
  return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
543
- 'use strict';
541
+ 'use strict'; /*# sourceURL=streamConfig.json */
544
542
  var vErrors = null;
545
543
  var errors = 0;
546
544
  if (rootData === undefined) rootData = data;
@@ -629,8 +627,8 @@ var validate = (function() {
629
627
  };
630
628
  })();
631
629
  validate.schema = {
632
- "id": "streamConfig.json",
633
- "$schema": "http://json-schema.org/draft-04/schema#",
630
+ "$id": "streamConfig.json",
631
+ "$schema": "http://json-schema.org/draft-06/schema#",
634
632
  "type": "object",
635
633
  "properties": {
636
634
  "border": {