console-table-printer
Advanced tools
Comparing version
@@ -16,4 +16,6 @@ "use strict"; | ||
var _a; | ||
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) })); | ||
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) })); | ||
}; | ||
exports.rawColumnToInternalColumn = rawColumnToInternalColumn; |
@@ -31,3 +31,4 @@ "use strict"; | ||
this.charLength = (options === null || options === void 0 ? void 0 : options.charLength) || this.charLength; | ||
this.defaultColumnOptions = (options === null || options === void 0 ? void 0 : options.defaultColumnOptions) || this.defaultColumnOptions; | ||
this.defaultColumnOptions = | ||
(options === null || options === void 0 ? void 0 : options.defaultColumnOptions) || this.defaultColumnOptions; | ||
if (options === null || options === void 0 ? void 0 : options.shouldDisableColors) { | ||
@@ -69,3 +70,3 @@ this.colorMap = {}; | ||
if (!colNames.includes(key)) { | ||
this.columns.push((0, table_helpers_1.createColumFromOnlyName)(key)); | ||
this.columns.push((0, input_converter_1.rawColumnToInternalColumn)((0, table_helpers_1.createColumFromOnlyName)(key), this.defaultColumnOptions)); | ||
} | ||
@@ -75,8 +76,6 @@ }); | ||
addColumn(textOrObj) { | ||
if (typeof textOrObj === 'string') { | ||
this.columns.push((0, table_helpers_1.createColumFromOnlyName)(textOrObj)); | ||
} | ||
else { | ||
this.columns.push((0, input_converter_1.rawColumnToInternalColumn)(textOrObj)); | ||
} | ||
const columnOptionsFromInput = typeof textOrObj === 'string' | ||
? (0, table_helpers_1.createColumFromOnlyName)(textOrObj) | ||
: textOrObj; | ||
this.columns.push((0, input_converter_1.rawColumnToInternalColumn)(columnOptionsFromInput, this.defaultColumnOptions)); | ||
} | ||
@@ -83,0 +82,0 @@ addColumns(toBeInsertedColumns) { |
import { ALIGNMENTS, COLORS } from '../utils/table-constants'; | ||
export type ALIGNMENT = typeof ALIGNMENTS[number]; | ||
export type COLOR = typeof COLORS[number]; | ||
export type ALIGNMENT = (typeof ALIGNMENTS)[number]; | ||
export type COLOR = (typeof COLORS)[number]; | ||
export interface Dictionary { | ||
@@ -5,0 +5,0 @@ [key: string]: any; |
@@ -19,3 +19,6 @@ import { CharLengthDict, COLOR, Dictionary, Row } from '../models/common'; | ||
}, column_lengths: number[]) => string; | ||
export declare const createColumFromOnlyName: (name: string) => Column; | ||
export declare const createColumFromOnlyName: (name: string) => { | ||
name: string; | ||
title: string; | ||
}; | ||
export declare const createRow: (color: COLOR, text: Dictionary, separator: boolean) => Row; | ||
@@ -22,0 +25,0 @@ export declare const findLenOfColumn: (column: Column, rows: Row[], charLength?: CharLengthDict) => number; |
{ | ||
"name": "console-table-printer", | ||
"version": "2.14.1", | ||
"version": "2.14.2", | ||
"repository": "github:console-table-printer/console-table-printer", | ||
@@ -5,0 +5,0 @@ "description": "Printing pretty tables on console log", |
46132
0.4%813
0.49%