table 6.0.9 → 6.3.1

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 (107) hide show
  1. package/README.md +53 -1
  2. package/dist/src/alignString.d.ts +6 -0
  3. package/dist/src/alignString.js +64 -0
  4. package/dist/src/alignTableData.d.ts +3 -0
  5. package/dist/src/alignTableData.js +21 -0
  6. package/dist/src/calculateCellHeight.d.ts +2 -0
  7. package/dist/src/calculateCellHeight.js +17 -0
  8. package/dist/src/calculateCellWidthIndex.d.ts +6 -0
  9. package/dist/src/calculateCellWidthIndex.js +17 -0
  10. package/dist/src/calculateMaximumColumnWidthIndex.d.ts +6 -0
  11. package/dist/src/calculateMaximumColumnWidthIndex.js +25 -0
  12. package/dist/src/calculateRowHeightIndex.d.ts +6 -0
  13. package/dist/src/calculateRowHeightIndex.js +30 -0
  14. package/dist/src/createStream.d.ts +3 -0
  15. package/dist/src/createStream.js +74 -0
  16. package/dist/src/drawBorder.d.ts +25 -0
  17. package/dist/src/drawBorder.js +55 -0
  18. package/dist/src/drawHorizontalContent.d.ts +11 -0
  19. package/dist/src/drawHorizontalContent.js +19 -0
  20. package/dist/src/drawRow.d.ts +7 -0
  21. package/dist/src/drawRow.js +17 -0
  22. package/dist/src/drawTable.d.ts +3 -0
  23. package/dist/src/drawTable.js +38 -0
  24. package/dist/src/getBorderCharacters.d.ts +3 -0
  25. package/dist/src/getBorderCharacters.js +83 -0
  26. package/dist/{index.js.flow → src/index.d.ts} +2 -6
  27. package/dist/src/index.js +24 -0
  28. package/dist/src/makeConfig.d.ts +8 -0
  29. package/dist/src/makeConfig.js +59 -0
  30. package/dist/src/makeStreamConfig.d.ts +8 -0
  31. package/dist/src/makeStreamConfig.js +60 -0
  32. package/dist/src/mapDataUsingRowHeightIndex.d.ts +3 -0
  33. package/dist/src/mapDataUsingRowHeightIndex.js +27 -0
  34. package/dist/src/padTableData.d.ts +3 -0
  35. package/dist/src/padTableData.js +11 -0
  36. package/dist/src/stringifyTableData.d.ts +3 -0
  37. package/dist/src/stringifyTableData.js +8 -0
  38. package/dist/src/table.d.ts +3 -0
  39. package/dist/src/table.js +28 -0
  40. package/dist/src/truncateTableData.d.ts +6 -0
  41. package/dist/src/truncateTableData.js +20 -0
  42. package/dist/src/types/api.d.ts +100 -0
  43. package/dist/src/types/api.js +3 -0
  44. package/dist/src/types/internal.d.ts +1 -0
  45. package/dist/src/types/internal.js +3 -0
  46. package/dist/src/validateConfig.d.ts +3 -0
  47. package/dist/src/validateConfig.js +27 -0
  48. package/dist/src/validateTableData.d.ts +2 -0
  49. package/dist/src/validateTableData.js +29 -0
  50. package/dist/{validators.js → src/validators.js} +54 -14
  51. package/dist/src/wrapCell.d.ts +9 -0
  52. package/dist/src/wrapCell.js +33 -0
  53. package/dist/src/wrapString.d.ts +10 -0
  54. package/dist/src/wrapString.js +25 -0
  55. package/dist/src/wrapWord.d.ts +2 -0
  56. package/dist/src/wrapWord.js +29 -0
  57. package/package.json +32 -25
  58. package/dist/alignString.js +0 -107
  59. package/dist/alignString.js.flow +0 -97
  60. package/dist/alignTableData.js +0 -34
  61. package/dist/alignTableData.js.flow +0 -21
  62. package/dist/calculateCellHeight.js +0 -37
  63. package/dist/calculateCellHeight.js.flow +0 -24
  64. package/dist/calculateCellWidthIndex.js +0 -27
  65. package/dist/calculateCellWidthIndex.js.flow +0 -17
  66. package/dist/calculateMaximumColumnWidthIndex.js +0 -36
  67. package/dist/calculateMaximumColumnWidthIndex.js.flow +0 -27
  68. package/dist/calculateRowHeightIndex.js +0 -45
  69. package/dist/calculateRowHeightIndex.js.flow +0 -36
  70. package/dist/createStream.js +0 -124
  71. package/dist/createStream.js.flow +0 -125
  72. package/dist/drawBorder.js +0 -109
  73. package/dist/drawBorder.js.flow +0 -101
  74. package/dist/drawRow.js +0 -25
  75. package/dist/drawRow.js.flow +0 -15
  76. package/dist/drawTable.js +0 -58
  77. package/dist/drawTable.js.flow +0 -53
  78. package/dist/getBorderCharacters.js +0 -118
  79. package/dist/getBorderCharacters.js.flow +0 -120
  80. package/dist/index.js +0 -31
  81. package/dist/makeConfig.js +0 -91
  82. package/dist/makeConfig.js.flow +0 -76
  83. package/dist/makeStreamConfig.js +0 -97
  84. package/dist/makeStreamConfig.js.flow +0 -83
  85. package/dist/mapDataUsingRowHeightIndex.js +0 -41
  86. package/dist/mapDataUsingRowHeightIndex.js.flow +0 -34
  87. package/dist/padTableData.js +0 -23
  88. package/dist/padTableData.js.flow +0 -14
  89. package/dist/schemas/config.json +0 -23
  90. package/dist/schemas/shared.json +0 -98
  91. package/dist/schemas/streamConfig.json +0 -20
  92. package/dist/stringifyTableData.js +0 -21
  93. package/dist/stringifyTableData.js.flow +0 -11
  94. package/dist/table.js +0 -109
  95. package/dist/table.js.flow +0 -96
  96. package/dist/truncateTableData.js +0 -29
  97. package/dist/truncateTableData.js.flow +0 -17
  98. package/dist/validateConfig.js +0 -40
  99. package/dist/validateConfig.js.flow +0 -27
  100. package/dist/validateTableData.js +0 -54
  101. package/dist/validateTableData.js.flow +0 -44
  102. package/dist/wrapCell.js +0 -47
  103. package/dist/wrapCell.js.flow +0 -35
  104. package/dist/wrapString.js +0 -39
  105. package/dist/wrapString.js.flow +0 -29
  106. package/dist/wrapWord.js +0 -46
  107. package/dist/wrapWord.js.flow +0 -39
@@ -1,118 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- /* eslint-disable sort-keys-fix/sort-keys-fix */
9
-
10
- /**
11
- * @typedef border
12
- * @property {string} topBody
13
- * @property {string} topJoin
14
- * @property {string} topLeft
15
- * @property {string} topRight
16
- * @property {string} bottomBody
17
- * @property {string} bottomJoin
18
- * @property {string} bottomLeft
19
- * @property {string} bottomRight
20
- * @property {string} bodyLeft
21
- * @property {string} bodyRight
22
- * @property {string} bodyJoin
23
- * @property {string} joinBody
24
- * @property {string} joinLeft
25
- * @property {string} joinRight
26
- * @property {string} joinJoin
27
- */
28
-
29
- /**
30
- * @param {string} name
31
- * @returns {border}
32
- */
33
- const getBorderCharacters = name => {
34
- if (name === 'honeywell') {
35
- return {
36
- topBody: '═',
37
- topJoin: '╤',
38
- topLeft: '╔',
39
- topRight: '╗',
40
- bottomBody: '═',
41
- bottomJoin: '╧',
42
- bottomLeft: '╚',
43
- bottomRight: '╝',
44
- bodyLeft: '║',
45
- bodyRight: '║',
46
- bodyJoin: '│',
47
- joinBody: '─',
48
- joinLeft: '╟',
49
- joinRight: '╢',
50
- joinJoin: '┼'
51
- };
52
- }
53
-
54
- if (name === 'norc') {
55
- return {
56
- topBody: '─',
57
- topJoin: '┬',
58
- topLeft: '┌',
59
- topRight: '┐',
60
- bottomBody: '─',
61
- bottomJoin: '┴',
62
- bottomLeft: '└',
63
- bottomRight: '┘',
64
- bodyLeft: '│',
65
- bodyRight: '│',
66
- bodyJoin: '│',
67
- joinBody: '─',
68
- joinLeft: '├',
69
- joinRight: '┤',
70
- joinJoin: '┼'
71
- };
72
- }
73
-
74
- if (name === 'ramac') {
75
- return {
76
- topBody: '-',
77
- topJoin: '+',
78
- topLeft: '+',
79
- topRight: '+',
80
- bottomBody: '-',
81
- bottomJoin: '+',
82
- bottomLeft: '+',
83
- bottomRight: '+',
84
- bodyLeft: '|',
85
- bodyRight: '|',
86
- bodyJoin: '|',
87
- joinBody: '-',
88
- joinLeft: '|',
89
- joinRight: '|',
90
- joinJoin: '|'
91
- };
92
- }
93
-
94
- if (name === 'void') {
95
- return {
96
- topBody: '',
97
- topJoin: '',
98
- topLeft: '',
99
- topRight: '',
100
- bottomBody: '',
101
- bottomJoin: '',
102
- bottomLeft: '',
103
- bottomRight: '',
104
- bodyLeft: '',
105
- bodyRight: '',
106
- bodyJoin: '',
107
- joinBody: '',
108
- joinLeft: '',
109
- joinRight: '',
110
- joinJoin: ''
111
- };
112
- }
113
-
114
- throw new Error('Unknown border template "' + name + '".');
115
- };
116
-
117
- var _default = getBorderCharacters;
118
- exports.default = _default;
@@ -1,120 +0,0 @@
1
- /* eslint-disable sort-keys-fix/sort-keys-fix */
2
-
3
- /**
4
- * @typedef border
5
- * @property {string} topBody
6
- * @property {string} topJoin
7
- * @property {string} topLeft
8
- * @property {string} topRight
9
- * @property {string} bottomBody
10
- * @property {string} bottomJoin
11
- * @property {string} bottomLeft
12
- * @property {string} bottomRight
13
- * @property {string} bodyLeft
14
- * @property {string} bodyRight
15
- * @property {string} bodyJoin
16
- * @property {string} joinBody
17
- * @property {string} joinLeft
18
- * @property {string} joinRight
19
- * @property {string} joinJoin
20
- */
21
-
22
- /**
23
- * @param {string} name
24
- * @returns {border}
25
- */
26
- export default (name) => {
27
- if (name === 'honeywell') {
28
- return {
29
- topBody: '═',
30
- topJoin: '╤',
31
- topLeft: '╔',
32
- topRight: '╗',
33
-
34
- bottomBody: '═',
35
- bottomJoin: '╧',
36
- bottomLeft: '╚',
37
- bottomRight: '╝',
38
-
39
- bodyLeft: '║',
40
- bodyRight: '║',
41
- bodyJoin: '│',
42
-
43
- joinBody: '─',
44
- joinLeft: '╟',
45
- joinRight: '╢',
46
- joinJoin: '┼',
47
- };
48
- }
49
-
50
- if (name === 'norc') {
51
- return {
52
- topBody: '─',
53
- topJoin: '┬',
54
- topLeft: '┌',
55
- topRight: '┐',
56
-
57
- bottomBody: '─',
58
- bottomJoin: '┴',
59
- bottomLeft: '└',
60
- bottomRight: '┘',
61
-
62
- bodyLeft: '│',
63
- bodyRight: '│',
64
- bodyJoin: '│',
65
-
66
- joinBody: '─',
67
- joinLeft: '├',
68
- joinRight: '┤',
69
- joinJoin: '┼',
70
- };
71
- }
72
-
73
- if (name === 'ramac') {
74
- return {
75
- topBody: '-',
76
- topJoin: '+',
77
- topLeft: '+',
78
- topRight: '+',
79
-
80
- bottomBody: '-',
81
- bottomJoin: '+',
82
- bottomLeft: '+',
83
- bottomRight: '+',
84
-
85
- bodyLeft: '|',
86
- bodyRight: '|',
87
- bodyJoin: '|',
88
-
89
- joinBody: '-',
90
- joinLeft: '|',
91
- joinRight: '|',
92
- joinJoin: '|',
93
- };
94
- }
95
-
96
- if (name === 'void') {
97
- return {
98
- topBody: '',
99
- topJoin: '',
100
- topLeft: '',
101
- topRight: '',
102
-
103
- bottomBody: '',
104
- bottomJoin: '',
105
- bottomLeft: '',
106
- bottomRight: '',
107
-
108
- bodyLeft: '',
109
- bodyRight: '',
110
- bodyJoin: '',
111
-
112
- joinBody: '',
113
- joinLeft: '',
114
- joinRight: '',
115
- joinJoin: '',
116
- };
117
- }
118
-
119
- throw new Error('Unknown border template "' + name + '".');
120
- };
package/dist/index.js DELETED
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "createStream", {
7
- enumerable: true,
8
- get: function () {
9
- return _createStream.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "getBorderCharacters", {
13
- enumerable: true,
14
- get: function () {
15
- return _getBorderCharacters.default;
16
- }
17
- });
18
- Object.defineProperty(exports, "table", {
19
- enumerable: true,
20
- get: function () {
21
- return _table.default;
22
- }
23
- });
24
-
25
- var _createStream = _interopRequireDefault(require("./createStream"));
26
-
27
- var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters"));
28
-
29
- var _table = _interopRequireDefault(require("./table"));
30
-
31
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,91 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
9
-
10
- var _calculateMaximumColumnWidthIndex = _interopRequireDefault(require("./calculateMaximumColumnWidthIndex"));
11
-
12
- var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters"));
13
-
14
- var _validateConfig = _interopRequireDefault(require("./validateConfig"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- /**
19
- * Merges user provided border characters with the default border ("honeywell") characters.
20
- *
21
- * @param {object} border
22
- * @returns {object}
23
- */
24
- const makeBorder = (border = {}) => {
25
- return Object.assign({}, (0, _getBorderCharacters.default)('honeywell'), border);
26
- };
27
- /**
28
- * Creates a configuration for every column using default
29
- * values for the missing configuration properties.
30
- *
31
- * @param {Array[]} rows
32
- * @param {object} columns
33
- * @param {object} columnDefault
34
- * @returns {object}
35
- */
36
-
37
-
38
- const makeColumns = (rows, columns = {}, columnDefault = {}) => {
39
- const maximumColumnWidthIndex = (0, _calculateMaximumColumnWidthIndex.default)(rows);
40
-
41
- for (let index = 0; index < rows[0].length; index++) {
42
- if (typeof columns[index] === 'undefined') {
43
- columns[index] = {};
44
- }
45
-
46
- columns[index] = Object.assign({
47
- alignment: 'left',
48
- paddingLeft: 1,
49
- paddingRight: 1,
50
- truncate: Number.POSITIVE_INFINITY,
51
- width: maximumColumnWidthIndex[index],
52
- wrapWord: false
53
- }, columnDefault, columns[index]);
54
- }
55
-
56
- return columns;
57
- };
58
- /**
59
- * Makes a new configuration object out of the userConfig object
60
- * using default values for the missing configuration properties.
61
- *
62
- * @param {Array[]} rows
63
- * @param {object} userConfig
64
- * @returns {object}
65
- */
66
-
67
-
68
- const makeConfig = (rows, userConfig = {}) => {
69
- (0, _validateConfig.default)('config.json', userConfig);
70
- const config = (0, _lodash.default)(userConfig);
71
- config.border = makeBorder(config.border);
72
- config.columns = makeColumns(rows, config.columns, config.columnDefault);
73
-
74
- if (!config.drawHorizontalLine) {
75
- /**
76
- * @returns {boolean}
77
- */
78
- config.drawHorizontalLine = () => {
79
- return true;
80
- };
81
- }
82
-
83
- if (config.singleLine === undefined) {
84
- config.singleLine = false;
85
- }
86
-
87
- return config;
88
- };
89
-
90
- var _default = makeConfig;
91
- exports.default = _default;
@@ -1,76 +0,0 @@
1
- import cloneDeep from 'lodash.clonedeep';
2
- import calculateMaximumColumnWidthIndex from './calculateMaximumColumnWidthIndex';
3
- import getBorderCharacters from './getBorderCharacters';
4
- import validateConfig from './validateConfig';
5
-
6
- /**
7
- * Merges user provided border characters with the default border ("honeywell") characters.
8
- *
9
- * @param {object} border
10
- * @returns {object}
11
- */
12
- const makeBorder = (border = {}) => {
13
- return Object.assign({}, getBorderCharacters('honeywell'), border);
14
- };
15
-
16
- /**
17
- * Creates a configuration for every column using default
18
- * values for the missing configuration properties.
19
- *
20
- * @param {Array[]} rows
21
- * @param {object} columns
22
- * @param {object} columnDefault
23
- * @returns {object}
24
- */
25
- const makeColumns = (rows, columns = {}, columnDefault = {}) => {
26
- const maximumColumnWidthIndex = calculateMaximumColumnWidthIndex(rows);
27
-
28
- for (let index = 0; index < rows[0].length; index++) {
29
- if (typeof columns[index] === 'undefined') {
30
- columns[index] = {};
31
- }
32
-
33
- columns[index] = Object.assign({
34
- alignment: 'left',
35
- paddingLeft: 1,
36
- paddingRight: 1,
37
- truncate: Number.POSITIVE_INFINITY,
38
- width: maximumColumnWidthIndex[index],
39
- wrapWord: false,
40
- }, columnDefault, columns[index]);
41
- }
42
-
43
- return columns;
44
- };
45
-
46
- /**
47
- * Makes a new configuration object out of the userConfig object
48
- * using default values for the missing configuration properties.
49
- *
50
- * @param {Array[]} rows
51
- * @param {object} userConfig
52
- * @returns {object}
53
- */
54
- export default (rows, userConfig = {}) => {
55
- validateConfig('config.json', userConfig);
56
-
57
- const config = cloneDeep(userConfig);
58
-
59
- config.border = makeBorder(config.border);
60
- config.columns = makeColumns(rows, config.columns, config.columnDefault);
61
-
62
- if (!config.drawHorizontalLine) {
63
- /**
64
- * @returns {boolean}
65
- */
66
- config.drawHorizontalLine = () => {
67
- return true;
68
- };
69
- }
70
-
71
- if (config.singleLine === undefined) {
72
- config.singleLine = false;
73
- }
74
-
75
- return config;
76
- };
@@ -1,97 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
9
-
10
- var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters"));
11
-
12
- var _validateConfig = _interopRequireDefault(require("./validateConfig"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- /**
17
- * Merges user provided border characters with the default border ("honeywell") characters.
18
- *
19
- * @param {object} border
20
- * @returns {object}
21
- */
22
- const makeBorder = (border = {}) => {
23
- return Object.assign({}, (0, _getBorderCharacters.default)('honeywell'), border);
24
- };
25
- /**
26
- * Creates a configuration for every column using default
27
- * values for the missing configuration properties.
28
- *
29
- * @param {number} columnCount
30
- * @param {object} columns
31
- * @param {object} columnDefault
32
- * @returns {object}
33
- */
34
-
35
-
36
- const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
37
- for (let index = 0; index < columnCount; index++) {
38
- if (typeof columns[index] === 'undefined') {
39
- columns[index] = {};
40
- }
41
-
42
- columns[index] = Object.assign({
43
- alignment: 'left',
44
- paddingLeft: 1,
45
- paddingRight: 1,
46
- truncate: Number.POSITIVE_INFINITY,
47
- wrapWord: false
48
- }, columnDefault, columns[index]);
49
- }
50
-
51
- return columns;
52
- };
53
- /**
54
- * @typedef {object} columnConfig
55
- * @property {string} alignment
56
- * @property {number} width
57
- * @property {number} truncate
58
- * @property {number} paddingLeft
59
- * @property {number} paddingRight
60
- */
61
-
62
- /**
63
- * @typedef {object} streamConfig
64
- * @property {columnConfig} columnDefault
65
- * @property {object} border
66
- * @property {columnConfig[]}
67
- * @property {number} columnCount Number of columns in the table (required).
68
- */
69
-
70
- /**
71
- * Makes a new configuration object out of the userConfig object
72
- * using default values for the missing configuration properties.
73
- *
74
- * @param {streamConfig} userConfig
75
- * @returns {object}
76
- */
77
-
78
-
79
- const makeStreamConfig = (userConfig = {}) => {
80
- (0, _validateConfig.default)('streamConfig.json', userConfig);
81
- const config = (0, _lodash.default)(userConfig);
82
-
83
- if (!config.columnDefault || !config.columnDefault.width) {
84
- throw new Error('Must provide config.columnDefault.width when creating a stream.');
85
- }
86
-
87
- if (!config.columnCount) {
88
- throw new Error('Must provide config.columnCount.');
89
- }
90
-
91
- config.border = makeBorder(config.border);
92
- config.columns = makeColumns(config.columnCount, config.columns, config.columnDefault);
93
- return config;
94
- };
95
-
96
- var _default = makeStreamConfig;
97
- exports.default = _default;
@@ -1,83 +0,0 @@
1
- import cloneDeep from 'lodash.clonedeep';
2
- import getBorderCharacters from './getBorderCharacters';
3
- import validateConfig from './validateConfig';
4
-
5
- /**
6
- * Merges user provided border characters with the default border ("honeywell") characters.
7
- *
8
- * @param {object} border
9
- * @returns {object}
10
- */
11
- const makeBorder = (border = {}) => {
12
- return Object.assign({}, getBorderCharacters('honeywell'), border);
13
- };
14
-
15
- /**
16
- * Creates a configuration for every column using default
17
- * values for the missing configuration properties.
18
- *
19
- * @param {number} columnCount
20
- * @param {object} columns
21
- * @param {object} columnDefault
22
- * @returns {object}
23
- */
24
- const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
25
- for (let index = 0; index < columnCount; index++) {
26
- if (typeof columns[index] === 'undefined') {
27
- columns[index] = {};
28
- }
29
-
30
- columns[index] = Object.assign({
31
- alignment: 'left',
32
- paddingLeft: 1,
33
- paddingRight: 1,
34
- truncate: Number.POSITIVE_INFINITY,
35
- wrapWord: false,
36
- }, columnDefault, columns[index]);
37
- }
38
-
39
- return columns;
40
- };
41
-
42
- /**
43
- * @typedef {object} columnConfig
44
- * @property {string} alignment
45
- * @property {number} width
46
- * @property {number} truncate
47
- * @property {number} paddingLeft
48
- * @property {number} paddingRight
49
- */
50
-
51
- /**
52
- * @typedef {object} streamConfig
53
- * @property {columnConfig} columnDefault
54
- * @property {object} border
55
- * @property {columnConfig[]}
56
- * @property {number} columnCount Number of columns in the table (required).
57
- */
58
-
59
- /**
60
- * Makes a new configuration object out of the userConfig object
61
- * using default values for the missing configuration properties.
62
- *
63
- * @param {streamConfig} userConfig
64
- * @returns {object}
65
- */
66
- export default (userConfig = {}) => {
67
- validateConfig('streamConfig.json', userConfig);
68
-
69
- const config = cloneDeep(userConfig);
70
-
71
- if (!config.columnDefault || !config.columnDefault.width) {
72
- throw new Error('Must provide config.columnDefault.width when creating a stream.');
73
- }
74
-
75
- if (!config.columnCount) {
76
- throw new Error('Must provide config.columnCount.');
77
- }
78
-
79
- config.border = makeBorder(config.border);
80
- config.columns = makeColumns(config.columnCount, config.columns, config.columnDefault);
81
-
82
- return config;
83
- };
@@ -1,41 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _lodash = _interopRequireDefault(require("lodash.flatten"));
9
-
10
- var _wrapCell = _interopRequireDefault(require("./wrapCell"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- /**
15
- * @param {Array} unmappedRows
16
- * @param {number[]} rowHeightIndex
17
- * @param {object} config
18
- * @returns {Array}
19
- */
20
- const mapDataUsingRowHeightIndex = (unmappedRows, rowHeightIndex, config) => {
21
- const tableWidth = unmappedRows[0].length;
22
- const mappedRows = unmappedRows.map((cells, index0) => {
23
- const rowHeight = Array.from(new Array(rowHeightIndex[index0]), () => {
24
- return new Array(tableWidth).fill('');
25
- }); // rowHeight
26
- // [{row index within rowSaw; index2}]
27
- // [{cell index within a virtual row; index1}]
28
-
29
- cells.forEach((value, index1) => {
30
- const cellLines = (0, _wrapCell.default)(value, config.columns[index1].width, config.columns[index1].wrapWord);
31
- cellLines.forEach((cellLine, index2) => {
32
- rowHeight[index2][index1] = cellLine;
33
- });
34
- });
35
- return rowHeight;
36
- });
37
- return (0, _lodash.default)(mappedRows);
38
- };
39
-
40
- var _default = mapDataUsingRowHeightIndex;
41
- exports.default = _default;
@@ -1,34 +0,0 @@
1
- import flatten from 'lodash.flatten';
2
- import wrapCell from './wrapCell';
3
-
4
- /**
5
- * @param {Array} unmappedRows
6
- * @param {number[]} rowHeightIndex
7
- * @param {object} config
8
- * @returns {Array}
9
- */
10
- export default (unmappedRows, rowHeightIndex, config) => {
11
- const tableWidth = unmappedRows[0].length;
12
-
13
- const mappedRows = unmappedRows.map((cells, index0) => {
14
- const rowHeight = Array.from(new Array(rowHeightIndex[index0]), () => {
15
- return new Array(tableWidth).fill('');
16
- });
17
-
18
- // rowHeight
19
- // [{row index within rowSaw; index2}]
20
- // [{cell index within a virtual row; index1}]
21
-
22
- cells.forEach((value, index1) => {
23
- const cellLines = wrapCell(value, config.columns[index1].width, config.columns[index1].wrapWord);
24
-
25
- cellLines.forEach((cellLine, index2) => {
26
- rowHeight[index2][index1] = cellLine;
27
- });
28
- });
29
-
30
- return rowHeight;
31
- });
32
-
33
- return flatten(mappedRows);
34
- };