console-table-printer 2.14.1 → 2.14.2

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.
@@ -13,6 +13,8 @@ const objIfExists = (key, val) => {
13
13
  exports.objIfExists = objIfExists;
14
14
  const rawColumnToInternalColumn = (column, defaultColumnStyles) => {
15
15
  var _a;
16
- return (Object.assign(Object.assign(Object.assign(Object.assign({ name: column.name, title: (_a = column.title) !== null && _a !== void 0 ? _a : column.name }, (0, exports.objIfExists)('color', (column.color || (defaultColumnStyles === null || defaultColumnStyles === void 0 ? void 0 : defaultColumnStyles.color)))), (0, exports.objIfExists)('maxLen', (column.maxLen || (defaultColumnStyles === null || defaultColumnStyles === void 0 ? void 0 : defaultColumnStyles.maxLen)))), (0, exports.objIfExists)('minLen', (column.minLen || (defaultColumnStyles === null || defaultColumnStyles === void 0 ? void 0 : defaultColumnStyles.minLen)))), { alignment: (column.alignment || (defaultColumnStyles === null || defaultColumnStyles === void 0 ? void 0 : defaultColumnStyles.alignment) || table_constants_1.DEFAULT_ROW_ALIGNMENT) }));
16
+ return (Object.assign(Object.assign(Object.assign(Object.assign({ name: column.name, title: (_a = column.title) !== null && _a !== void 0 ? _a : column.name }, (0, exports.objIfExists)('color', (column.color || (defaultColumnStyles === null || defaultColumnStyles === void 0 ? void 0 : defaultColumnStyles.color)))), (0, exports.objIfExists)('maxLen', (column.maxLen || (defaultColumnStyles === null || defaultColumnStyles === void 0 ? void 0 : defaultColumnStyles.maxLen)))), (0, exports.objIfExists)('minLen', (column.minLen || (defaultColumnStyles === null || defaultColumnStyles === void 0 ? void 0 : defaultColumnStyles.minLen)))), { alignment: (column.alignment ||
17
+ (defaultColumnStyles === null || defaultColumnStyles === void 0 ? void 0 : defaultColumnStyles.alignment) ||
18
+ table_constants_1.DEFAULT_ROW_ALIGNMENT) }));
17
19
  };
18
20
  exports.rawColumnToInternalColumn = rawColumnToInternalColumn;
@@ -28,7 +28,8 @@ class TableInternal {
28
28
  ((_a = options === null || options === void 0 ? void 0 : options.columns) === null || _a === void 0 ? void 0 : _a.map((column) => (0, input_converter_1.rawColumnToInternalColumn)(column, options === null || options === void 0 ? void 0 : options.defaultColumnOptions))) || this.columns;
29
29
  this.rowSeparator = (options === null || options === void 0 ? void 0 : options.rowSeparator) || this.rowSeparator;
30
30
  this.charLength = (options === null || options === void 0 ? void 0 : options.charLength) || this.charLength;
31
- this.defaultColumnOptions = (options === null || options === void 0 ? void 0 : options.defaultColumnOptions) || this.defaultColumnOptions;
31
+ this.defaultColumnOptions =
32
+ (options === null || options === void 0 ? void 0 : options.defaultColumnOptions) || this.defaultColumnOptions;
32
33
  if (options === null || options === void 0 ? void 0 : options.shouldDisableColors) {
33
34
  this.colorMap = {};
34
35
  }
@@ -65,17 +66,15 @@ class TableInternal {
65
66
  const colNames = this.columns.map((col) => col.name);
66
67
  Object.keys(text).forEach((key) => {
67
68
  if (!colNames.includes(key)) {
68
- this.columns.push((0, table_helpers_1.createColumFromOnlyName)(key));
69
+ this.columns.push((0, input_converter_1.rawColumnToInternalColumn)((0, table_helpers_1.createColumFromOnlyName)(key), this.defaultColumnOptions));
69
70
  }
70
71
  });
71
72
  }
72
73
  addColumn(textOrObj) {
73
- if (typeof textOrObj === 'string') {
74
- this.columns.push((0, table_helpers_1.createColumFromOnlyName)(textOrObj));
75
- }
76
- else {
77
- this.columns.push((0, input_converter_1.rawColumnToInternalColumn)(textOrObj));
78
- }
74
+ const columnOptionsFromInput = typeof textOrObj === 'string'
75
+ ? (0, table_helpers_1.createColumFromOnlyName)(textOrObj)
76
+ : textOrObj;
77
+ this.columns.push((0, input_converter_1.rawColumnToInternalColumn)(columnOptionsFromInput, this.defaultColumnOptions));
79
78
  }
80
79
  addColumns(toBeInsertedColumns) {
81
80
  toBeInsertedColumns.forEach((toBeInsertedColumn) => {
@@ -1,6 +1,6 @@
1
1
  import { ALIGNMENTS, COLORS } from '../utils/table-constants';
2
- export type ALIGNMENT = typeof ALIGNMENTS[number];
3
- export type COLOR = typeof COLORS[number];
2
+ export type ALIGNMENT = (typeof ALIGNMENTS)[number];
3
+ export type COLOR = (typeof COLORS)[number];
4
4
  export interface Dictionary {
5
5
  [key: string]: any;
6
6
  }
@@ -16,7 +16,10 @@ export declare const createTableHorizontalBorders: ({ left, mid, right, other, }
16
16
  right: string;
17
17
  other: string;
18
18
  }, column_lengths: number[]) => string;
19
- export declare const createColumFromOnlyName: (name: string) => Column;
19
+ export declare const createColumFromOnlyName: (name: string) => {
20
+ name: string;
21
+ title: string;
22
+ };
20
23
  export declare const createRow: (color: COLOR, text: Dictionary, separator: boolean) => Row;
21
24
  export declare const findLenOfColumn: (column: Column, rows: Row[], charLength?: CharLengthDict) => number;
22
25
  export declare const renderTableHorizontalBorders: (style: any, column_lengths: number[]) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "console-table-printer",
3
- "version": "2.14.1",
3
+ "version": "2.14.2",
4
4
  "repository": "github:console-table-printer/console-table-printer",
5
5
  "description": "Printing pretty tables on console log",
6
6
  "main": "dist/index.js",