table 6.0.8 → 6.3.0

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 (106) hide show
  1. package/README.md +53 -1
  2. package/dist/src/alignString.js +64 -0
  3. package/dist/src/alignTableData.js +21 -0
  4. package/dist/src/calculateCellHeight.js +17 -0
  5. package/dist/src/calculateCellWidthIndex.js +17 -0
  6. package/dist/src/calculateMaximumColumnWidthIndex.js +25 -0
  7. package/dist/src/calculateRowHeightIndex.js +30 -0
  8. package/dist/src/createStream.js +74 -0
  9. package/dist/src/drawBorder.js +55 -0
  10. package/dist/src/drawHorizontalContent.js +19 -0
  11. package/dist/src/drawRow.js +17 -0
  12. package/dist/src/drawTable.js +38 -0
  13. package/dist/src/getBorderCharacters.js +83 -0
  14. package/dist/{index.js.flow → src/index.d.ts} +2 -6
  15. package/dist/src/index.js +24 -0
  16. package/dist/src/makeConfig.js +59 -0
  17. package/dist/src/makeStreamConfig.js +60 -0
  18. package/dist/src/mapDataUsingRowHeightIndex.js +27 -0
  19. package/dist/src/padTableData.js +11 -0
  20. package/dist/src/stringifyTableData.js +8 -0
  21. package/dist/src/table.js +28 -0
  22. package/dist/src/truncateTableData.js +20 -0
  23. package/dist/src/types/api.d.ts +99 -0
  24. package/dist/src/types/api.js +3 -0
  25. package/dist/src/types/internal.js +3 -0
  26. package/dist/src/validateConfig.js +27 -0
  27. package/dist/src/validateTableData.js +29 -0
  28. package/dist/{validators.js → src/validators.js} +54 -14
  29. package/dist/src/wrapCell.js +33 -0
  30. package/dist/src/wrapString.js +25 -0
  31. package/dist/src/wrapWord.js +29 -0
  32. package/package.json +33 -26
  33. package/dist/alignString.js +0 -108
  34. package/dist/alignString.js.flow +0 -97
  35. package/dist/alignString.js.map +0 -1
  36. package/dist/alignTableData.js +0 -35
  37. package/dist/alignTableData.js.flow +0 -21
  38. package/dist/alignTableData.js.map +0 -1
  39. package/dist/calculateCellHeight.js +0 -38
  40. package/dist/calculateCellHeight.js.flow +0 -24
  41. package/dist/calculateCellHeight.js.map +0 -1
  42. package/dist/calculateCellWidthIndex.js +0 -28
  43. package/dist/calculateCellWidthIndex.js.flow +0 -17
  44. package/dist/calculateCellWidthIndex.js.map +0 -1
  45. package/dist/calculateMaximumColumnWidthIndex.js +0 -37
  46. package/dist/calculateMaximumColumnWidthIndex.js.flow +0 -27
  47. package/dist/calculateMaximumColumnWidthIndex.js.map +0 -1
  48. package/dist/calculateRowHeightIndex.js +0 -46
  49. package/dist/calculateRowHeightIndex.js.flow +0 -36
  50. package/dist/calculateRowHeightIndex.js.map +0 -1
  51. package/dist/createStream.js +0 -125
  52. package/dist/createStream.js.flow +0 -125
  53. package/dist/createStream.js.map +0 -1
  54. package/dist/drawBorder.js +0 -110
  55. package/dist/drawBorder.js.flow +0 -101
  56. package/dist/drawBorder.js.map +0 -1
  57. package/dist/drawRow.js +0 -26
  58. package/dist/drawRow.js.flow +0 -15
  59. package/dist/drawRow.js.map +0 -1
  60. package/dist/drawTable.js +0 -59
  61. package/dist/drawTable.js.flow +0 -53
  62. package/dist/drawTable.js.map +0 -1
  63. package/dist/getBorderCharacters.js +0 -119
  64. package/dist/getBorderCharacters.js.flow +0 -120
  65. package/dist/getBorderCharacters.js.map +0 -1
  66. package/dist/index.js +0 -32
  67. package/dist/index.js.map +0 -1
  68. package/dist/makeConfig.js +0 -92
  69. package/dist/makeConfig.js.flow +0 -76
  70. package/dist/makeConfig.js.map +0 -1
  71. package/dist/makeStreamConfig.js +0 -98
  72. package/dist/makeStreamConfig.js.flow +0 -83
  73. package/dist/makeStreamConfig.js.map +0 -1
  74. package/dist/mapDataUsingRowHeightIndex.js +0 -42
  75. package/dist/mapDataUsingRowHeightIndex.js.flow +0 -34
  76. package/dist/mapDataUsingRowHeightIndex.js.map +0 -1
  77. package/dist/padTableData.js +0 -24
  78. package/dist/padTableData.js.flow +0 -14
  79. package/dist/padTableData.js.map +0 -1
  80. package/dist/schemas/config.json +0 -23
  81. package/dist/schemas/shared.json +0 -98
  82. package/dist/schemas/streamConfig.json +0 -20
  83. package/dist/stringifyTableData.js +0 -22
  84. package/dist/stringifyTableData.js.flow +0 -11
  85. package/dist/stringifyTableData.js.map +0 -1
  86. package/dist/table.js +0 -110
  87. package/dist/table.js.flow +0 -96
  88. package/dist/table.js.map +0 -1
  89. package/dist/truncateTableData.js +0 -30
  90. package/dist/truncateTableData.js.flow +0 -17
  91. package/dist/truncateTableData.js.map +0 -1
  92. package/dist/validateConfig.js +0 -41
  93. package/dist/validateConfig.js.flow +0 -27
  94. package/dist/validateConfig.js.map +0 -1
  95. package/dist/validateTableData.js +0 -55
  96. package/dist/validateTableData.js.flow +0 -44
  97. package/dist/validateTableData.js.map +0 -1
  98. package/dist/wrapCell.js +0 -48
  99. package/dist/wrapCell.js.flow +0 -35
  100. package/dist/wrapCell.js.map +0 -1
  101. package/dist/wrapString.js +0 -40
  102. package/dist/wrapString.js.flow +0 -29
  103. package/dist/wrapString.js.map +0 -1
  104. package/dist/wrapWord.js +0 -47
  105. package/dist/wrapWord.js.flow +0 -39
  106. package/dist/wrapWord.js.map +0 -1
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
7
+ const getBorderCharacters_1 = __importDefault(require("./getBorderCharacters"));
8
+ const validateConfig_1 = __importDefault(require("./validateConfig"));
9
+ /**
10
+ * Merges user provided border characters with the default border ("honeywell") characters.
11
+ *
12
+ */
13
+ const makeBorder = (border) => {
14
+ return {
15
+ ...getBorderCharacters_1.default('honeywell'),
16
+ ...border,
17
+ };
18
+ };
19
+ /**
20
+ * Creates a configuration for every column using default
21
+ * values for the missing configuration properties.
22
+ */
23
+ const makeColumns = (columnCount, columns = {}, columnDefault) => {
24
+ return Array.from({ length: columnCount }).map((_, index) => {
25
+ return {
26
+ alignment: 'left',
27
+ paddingLeft: 1,
28
+ paddingRight: 1,
29
+ truncate: Number.POSITIVE_INFINITY,
30
+ wrapWord: false,
31
+ ...columnDefault,
32
+ ...columns[index],
33
+ };
34
+ });
35
+ };
36
+ /**
37
+ * Makes a new configuration object out of the userConfig object
38
+ * using default values for the missing configuration properties.
39
+ */
40
+ exports.default = (userConfig) => {
41
+ var _a;
42
+ validateConfig_1.default('streamConfig.json', userConfig);
43
+ const config = lodash_clonedeep_1.default(userConfig);
44
+ if (!config.columnDefault || !config.columnDefault.width) {
45
+ throw new Error('Must provide config.columnDefault.width when creating a stream.');
46
+ }
47
+ if (!config.columnCount) {
48
+ throw new Error('Must provide config.columnCount.');
49
+ }
50
+ return {
51
+ ...config,
52
+ border: makeBorder(config.border),
53
+ columnCount: config.columnCount,
54
+ columns: makeColumns(config.columnCount, config.columns, config.columnDefault),
55
+ drawVerticalLine: (_a = config.drawVerticalLine) !== null && _a !== void 0 ? _a : (() => {
56
+ return true;
57
+ }),
58
+ };
59
+ };
60
+ //# sourceMappingURL=makeStreamConfig.js.map
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const lodash_flatten_1 = __importDefault(require("lodash.flatten"));
7
+ const wrapCell_1 = __importDefault(require("./wrapCell"));
8
+ exports.default = (unmappedRows, rowHeightIndex, config) => {
9
+ const tableWidth = unmappedRows[0].length;
10
+ const mappedRows = unmappedRows.map((row, index0) => {
11
+ const rowHeight = Array.from({ length: rowHeightIndex[index0] }, () => {
12
+ return new Array(tableWidth).fill('');
13
+ });
14
+ // rowHeight
15
+ // [{row index within rowSaw; index2}]
16
+ // [{cell index within a virtual row; index1}]
17
+ row.forEach((cell, index1) => {
18
+ const cellLines = wrapCell_1.default(cell, config.columns[index1].width, config.columns[index1].wrapWord);
19
+ cellLines.forEach((cellLine, index2) => {
20
+ rowHeight[index2][index1] = cellLine;
21
+ });
22
+ });
23
+ return rowHeight;
24
+ });
25
+ return lodash_flatten_1.default(mappedRows);
26
+ };
27
+ //# sourceMappingURL=mapDataUsingRowHeightIndex.js.map
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = (rows, config) => {
4
+ return rows.map((cells) => {
5
+ return cells.map((value, index1) => {
6
+ const column = config.columns[index1];
7
+ return ' '.repeat(column.paddingLeft) + value + ' '.repeat(column.paddingRight);
8
+ });
9
+ });
10
+ };
11
+ //# sourceMappingURL=padTableData.js.map
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = (rows) => {
4
+ return rows.map((cells) => {
5
+ return cells.map(String);
6
+ });
7
+ };
8
+ //# sourceMappingURL=stringifyTableData.js.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const alignTableData_1 = __importDefault(require("./alignTableData"));
7
+ const calculateCellWidthIndex_1 = __importDefault(require("./calculateCellWidthIndex"));
8
+ const calculateRowHeightIndex_1 = __importDefault(require("./calculateRowHeightIndex"));
9
+ const drawTable_1 = __importDefault(require("./drawTable"));
10
+ const makeConfig_1 = __importDefault(require("./makeConfig"));
11
+ const mapDataUsingRowHeightIndex_1 = __importDefault(require("./mapDataUsingRowHeightIndex"));
12
+ const padTableData_1 = __importDefault(require("./padTableData"));
13
+ const stringifyTableData_1 = __importDefault(require("./stringifyTableData"));
14
+ const truncateTableData_1 = __importDefault(require("./truncateTableData"));
15
+ const validateTableData_1 = __importDefault(require("./validateTableData"));
16
+ exports.default = (data, userConfig = {}) => {
17
+ validateTableData_1.default(data);
18
+ let rows = stringifyTableData_1.default(data);
19
+ const config = makeConfig_1.default(rows, userConfig);
20
+ rows = truncateTableData_1.default(rows, config);
21
+ const rowHeightIndex = calculateRowHeightIndex_1.default(rows, config);
22
+ rows = mapDataUsingRowHeightIndex_1.default(rows, rowHeightIndex, config);
23
+ rows = alignTableData_1.default(rows, config);
24
+ rows = padTableData_1.default(rows, config);
25
+ const cellWidthIndex = calculateCellWidthIndex_1.default(rows[0]);
26
+ return drawTable_1.default(rows, cellWidthIndex, rowHeightIndex, config);
27
+ };
28
+ //# sourceMappingURL=table.js.map
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const lodash_truncate_1 = __importDefault(require("lodash.truncate"));
7
+ /**
8
+ * @todo Make it work with ASCII content.
9
+ */
10
+ exports.default = (rows, config) => {
11
+ return rows.map((cells) => {
12
+ return cells.map((content, index) => {
13
+ return lodash_truncate_1.default(content, {
14
+ length: config.columns[index].truncate,
15
+ omission: '…',
16
+ });
17
+ });
18
+ });
19
+ };
20
+ //# sourceMappingURL=truncateTableData.js.map
@@ -0,0 +1,99 @@
1
+ export declare type DrawLinePredicate = (index: number, size: number) => boolean;
2
+ export declare type DrawVerticalLine = DrawLinePredicate;
3
+ export declare type DrawHorizontalLine = DrawLinePredicate;
4
+ export declare type BorderUserConfig = {
5
+ readonly topLeft?: string;
6
+ readonly topRight?: string;
7
+ readonly topBody?: string;
8
+ readonly topJoin?: string;
9
+ readonly bottomLeft?: string;
10
+ readonly bottomRight?: string;
11
+ readonly bottomBody?: string;
12
+ readonly bottomJoin?: string;
13
+ readonly bodyRight?: string;
14
+ readonly bodyLeft?: string;
15
+ readonly bodyJoin?: string;
16
+ readonly joinLeft?: string;
17
+ readonly joinRight?: string;
18
+ readonly joinBody?: string;
19
+ readonly joinJoin?: string;
20
+ };
21
+ export declare type ColumnUserConfig = {
22
+ /**
23
+ * Cell content horizontal alignment (default: left)
24
+ */
25
+ readonly alignment?: 'center' | 'left' | 'right';
26
+ /**
27
+ * Column width (default: auto calculation based on the cell content)
28
+ */
29
+ readonly width?: number;
30
+ /**
31
+ * Number of characters are which the content will be truncated (default: Infinity)
32
+ */
33
+ readonly truncate?: number;
34
+ /**
35
+ * Cell content padding width left (default: 1)
36
+ */
37
+ readonly paddingLeft?: number;
38
+ /**
39
+ * Cell content padding width right (default: 1)
40
+ */
41
+ readonly paddingRight?: number;
42
+ /**
43
+ * If true, the text is broken at the nearest space or one of the special characters: "\|/_.,;-"
44
+ */
45
+ readonly wrapWord?: boolean;
46
+ };
47
+ export declare type BaseUserConfig = {
48
+ /**
49
+ * Custom border
50
+ */
51
+ readonly border?: BorderUserConfig;
52
+ /**
53
+ * Default values for all columns. Column specific settings overwrite the default values.
54
+ */
55
+ readonly columnDefault?: ColumnUserConfig;
56
+ /**
57
+ * Column specific configuration.
58
+ */
59
+ readonly columns?: Indexable<ColumnUserConfig>;
60
+ /**
61
+ * Used to tell whether to draw a vertical line.
62
+ * This callback is called for each non-content line of the table.
63
+ * The default behavior is to always return true.
64
+ */
65
+ readonly drawVerticalLine?: DrawVerticalLine;
66
+ };
67
+ export declare type TableUserConfig = BaseUserConfig & {
68
+ /**
69
+ * Used to tell whether to draw a horizontal line.
70
+ * This callback is called for each non-content line of the table.
71
+ * The default behavior is to always return true.
72
+ */
73
+ readonly drawHorizontalLine?: DrawHorizontalLine;
74
+ /**
75
+ * Horizontal lines inside the table are not drawn.
76
+ */
77
+ readonly singleLine?: boolean;
78
+ };
79
+ export declare type StreamUserConfig = BaseUserConfig & {
80
+ /**
81
+ * The number of columns
82
+ */
83
+ readonly columnCount: number;
84
+ /**
85
+ * Default values for all columns. Column specific settings overwrite the default values.
86
+ */
87
+ readonly columnDefault: ColumnUserConfig & {
88
+ /**
89
+ * The default width for each column
90
+ */
91
+ readonly width: number;
92
+ };
93
+ };
94
+ export declare type WritableStream = {
95
+ readonly write: (rows: string[]) => void;
96
+ };
97
+ export declare type Indexable<T> = {
98
+ readonly [index: number]: T;
99
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
7
+ // @ts-expect-error
8
+ // eslint-disable-next-line import/no-unresolved
9
+ const validators_1 = __importDefault(require("./validators"));
10
+ exports.default = (schemaId, config) => {
11
+ const validate = validators_1.default[schemaId];
12
+ if (!validate(config)) {
13
+ const errors = validate.errors.map((error) => {
14
+ return {
15
+ message: error.message,
16
+ params: error.params,
17
+ schemaPath: error.schemaPath,
18
+ };
19
+ });
20
+ /* eslint-disable no-console */
21
+ console.log('config', config);
22
+ console.log('errors', errors);
23
+ /* eslint-enable no-console */
24
+ throw new Error('Invalid config.');
25
+ }
26
+ };
27
+ //# sourceMappingURL=validateConfig.js.map
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = (rows) => {
4
+ if (!Array.isArray(rows)) {
5
+ throw new TypeError('Table data must be an array.');
6
+ }
7
+ if (rows.length === 0) {
8
+ throw new Error('Table must define at least one row.');
9
+ }
10
+ if (rows[0].length === 0) {
11
+ throw new Error('Table must define at least one column.');
12
+ }
13
+ const columnNumber = rows[0].length;
14
+ for (const row of rows) {
15
+ if (!Array.isArray(row)) {
16
+ throw new TypeError('Table row data must be an array.');
17
+ }
18
+ if (row.length !== columnNumber) {
19
+ throw new Error('Table must have a consistent number of cells.');
20
+ }
21
+ for (const cell of row) {
22
+ // eslint-disable-next-line no-control-regex
23
+ if (/[\u0001-\u0006\u0008\u0009\u000B-\u001A]/.test(cell)) {
24
+ throw new Error('Table data must not contain control characters.');
25
+ }
26
+ }
27
+ }
28
+ };
29
+ //# sourceMappingURL=validateTableData.js.map
@@ -14,6 +14,9 @@ const schema13 = {
14
14
  "columnDefault": {
15
15
  "$ref": "shared.json#/definitions/column"
16
16
  },
17
+ "drawVerticalLine": {
18
+ "typeof": "function"
19
+ },
17
20
  "drawHorizontalLine": {
18
21
  "typeof": "function"
19
22
  },
@@ -801,7 +804,7 @@ function validate43(data, {
801
804
  let errors = 0;
802
805
  if (data && typeof data == "object" && !Array.isArray(data)) {
803
806
  for (const key0 in data) {
804
- if (!(((((key0 === "border") || (key0 === "columns")) || (key0 === "columnDefault")) || (key0 === "drawHorizontalLine")) || (key0 === "singleLine"))) {
807
+ if (!((((((key0 === "border") || (key0 === "columns")) || (key0 === "columnDefault")) || (key0 === "drawVerticalLine")) || (key0 === "drawHorizontalLine")) || (key0 === "singleLine"))) {
805
808
  const err0 = {
806
809
  instancePath,
807
810
  schemaPath: "#/additionalProperties",
@@ -852,9 +855,26 @@ function validate43(data, {
852
855
  errors = vErrors.length;
853
856
  }
854
857
  }
858
+ if (data.drawVerticalLine !== undefined) {
859
+ if (typeof data.drawVerticalLine != "function") {
860
+ const err1 = {
861
+ instancePath: instancePath + "/drawVerticalLine",
862
+ schemaPath: "#/properties/drawVerticalLine/typeof",
863
+ keyword: "typeof",
864
+ params: {},
865
+ message: "should pass \"typeof\" keyword validation"
866
+ };
867
+ if (vErrors === null) {
868
+ vErrors = [err1];
869
+ } else {
870
+ vErrors.push(err1);
871
+ }
872
+ errors++;
873
+ }
874
+ }
855
875
  if (data.drawHorizontalLine !== undefined) {
856
876
  if (typeof data.drawHorizontalLine != "function") {
857
- const err1 = {
877
+ const err2 = {
858
878
  instancePath: instancePath + "/drawHorizontalLine",
859
879
  schemaPath: "#/properties/drawHorizontalLine/typeof",
860
880
  keyword: "typeof",
@@ -862,16 +882,16 @@ function validate43(data, {
862
882
  message: "should pass \"typeof\" keyword validation"
863
883
  };
864
884
  if (vErrors === null) {
865
- vErrors = [err1];
885
+ vErrors = [err2];
866
886
  } else {
867
- vErrors.push(err1);
887
+ vErrors.push(err2);
868
888
  }
869
889
  errors++;
870
890
  }
871
891
  }
872
892
  if (data.singleLine !== undefined) {
873
893
  if (typeof data.singleLine != "boolean") {
874
- const err2 = {
894
+ const err3 = {
875
895
  instancePath: instancePath + "/singleLine",
876
896
  schemaPath: "#/properties/singleLine/typeof",
877
897
  keyword: "typeof",
@@ -879,15 +899,15 @@ function validate43(data, {
879
899
  message: "should pass \"typeof\" keyword validation"
880
900
  };
881
901
  if (vErrors === null) {
882
- vErrors = [err2];
902
+ vErrors = [err3];
883
903
  } else {
884
- vErrors.push(err2);
904
+ vErrors.push(err3);
885
905
  }
886
906
  errors++;
887
907
  }
888
908
  }
889
909
  } else {
890
- const err3 = {
910
+ const err4 = {
891
911
  instancePath,
892
912
  schemaPath: "#/type",
893
913
  keyword: "type",
@@ -897,9 +917,9 @@ function validate43(data, {
897
917
  message: "must be object"
898
918
  };
899
919
  if (vErrors === null) {
900
- vErrors = [err3];
920
+ vErrors = [err4];
901
921
  } else {
902
- vErrors.push(err3);
922
+ vErrors.push(err4);
903
923
  }
904
924
  errors++;
905
925
  }
@@ -923,6 +943,9 @@ const schema20 = {
923
943
  },
924
944
  "columnCount": {
925
945
  "type": "number"
946
+ },
947
+ "drawVerticalLine": {
948
+ "typeof": "function"
926
949
  }
927
950
  },
928
951
  "additionalProperties": false
@@ -1400,7 +1423,7 @@ function validate69(data, {
1400
1423
  let errors = 0;
1401
1424
  if (data && typeof data == "object" && !Array.isArray(data)) {
1402
1425
  for (const key0 in data) {
1403
- if (!((((key0 === "border") || (key0 === "columns")) || (key0 === "columnDefault")) || (key0 === "columnCount"))) {
1426
+ if (!(((((key0 === "border") || (key0 === "columns")) || (key0 === "columnDefault")) || (key0 === "columnCount")) || (key0 === "drawVerticalLine"))) {
1404
1427
  const err0 = {
1405
1428
  instancePath,
1406
1429
  schemaPath: "#/additionalProperties",
@@ -1471,8 +1494,25 @@ function validate69(data, {
1471
1494
  errors++;
1472
1495
  }
1473
1496
  }
1497
+ if (data.drawVerticalLine !== undefined) {
1498
+ if (typeof data.drawVerticalLine != "function") {
1499
+ const err2 = {
1500
+ instancePath: instancePath + "/drawVerticalLine",
1501
+ schemaPath: "#/properties/drawVerticalLine/typeof",
1502
+ keyword: "typeof",
1503
+ params: {},
1504
+ message: "should pass \"typeof\" keyword validation"
1505
+ };
1506
+ if (vErrors === null) {
1507
+ vErrors = [err2];
1508
+ } else {
1509
+ vErrors.push(err2);
1510
+ }
1511
+ errors++;
1512
+ }
1513
+ }
1474
1514
  } else {
1475
- const err2 = {
1515
+ const err3 = {
1476
1516
  instancePath,
1477
1517
  schemaPath: "#/type",
1478
1518
  keyword: "type",
@@ -1482,9 +1522,9 @@ function validate69(data, {
1482
1522
  message: "must be object"
1483
1523
  };
1484
1524
  if (vErrors === null) {
1485
- vErrors = [err2];
1525
+ vErrors = [err3];
1486
1526
  } else {
1487
- vErrors.push(err2);
1527
+ vErrors.push(err3);
1488
1528
  }
1489
1529
  errors++;
1490
1530
  }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const wrapString_1 = __importDefault(require("./wrapString"));
7
+ const wrapWord_1 = __importDefault(require("./wrapWord"));
8
+ /**
9
+ * Wrap a single cell value into a list of lines
10
+ *
11
+ * Always wraps on newlines, for the remainder uses either word or string wrapping
12
+ * depending on user configuration.
13
+ *
14
+ */
15
+ exports.default = (cellValue, columnWidth, useWrapWord) => {
16
+ // First split on literal newlines
17
+ const cellLines = cellValue.split('\n');
18
+ // Then iterate over the list and word-wrap every remaining line if necessary.
19
+ for (let lineNr = 0; lineNr < cellLines.length;) {
20
+ let lineChunks;
21
+ if (useWrapWord) {
22
+ lineChunks = wrapWord_1.default(cellLines[lineNr], columnWidth);
23
+ }
24
+ else {
25
+ lineChunks = wrapString_1.default(cellLines[lineNr], columnWidth);
26
+ }
27
+ // Replace our original array element with whatever the wrapping returned
28
+ cellLines.splice(lineNr, 1, ...lineChunks);
29
+ lineNr += lineChunks.length;
30
+ }
31
+ return cellLines;
32
+ };
33
+ //# sourceMappingURL=wrapCell.js.map
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const slice_ansi_1 = __importDefault(require("slice-ansi"));
7
+ const string_width_1 = __importDefault(require("string-width"));
8
+ /**
9
+ * Creates an array of strings split into groups the length of size.
10
+ * This function works with strings that contain ASCII characters.
11
+ *
12
+ * wrapText is different from would-be "chunk" implementation
13
+ * in that whitespace characters that occur on a chunk size limit are trimmed.
14
+ *
15
+ */
16
+ exports.default = (subject, size) => {
17
+ let subjectSlice = subject;
18
+ const chunks = [];
19
+ do {
20
+ chunks.push(slice_ansi_1.default(subjectSlice, 0, size));
21
+ subjectSlice = slice_ansi_1.default(subjectSlice, size).trim();
22
+ } while (string_width_1.default(subjectSlice));
23
+ return chunks;
24
+ };
25
+ //# sourceMappingURL=wrapString.js.map
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const slice_ansi_1 = __importDefault(require("slice-ansi"));
7
+ const string_width_1 = __importDefault(require("string-width"));
8
+ exports.default = (input, size) => {
9
+ let subject = input;
10
+ const chunks = [];
11
+ // https://regex101.com/r/gY5kZ1/1
12
+ const re = new RegExp('(^.{1,' + String(size) + '}(\\s+|$))|(^.{1,' + String(size - 1) + '}(\\\\|/|_|\\.|,|;|-))');
13
+ do {
14
+ let chunk;
15
+ chunk = re.exec(subject);
16
+ if (chunk) {
17
+ chunk = chunk[0];
18
+ subject = slice_ansi_1.default(subject, string_width_1.default(chunk));
19
+ chunk = chunk.trim();
20
+ }
21
+ else {
22
+ chunk = slice_ansi_1.default(subject, 0, size);
23
+ subject = slice_ansi_1.default(subject, size);
24
+ }
25
+ chunks.push(chunk);
26
+ } while (string_width_1.default(subject));
27
+ return chunks;
28
+ };
29
+ //# sourceMappingURL=wrapWord.js.map