Socket
Socket
Sign inDemoInstall

console-table-printer

Package Overview
Dependencies
1
Maintainers
1
Versions
265
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.11.1 to 2.11.2

5

dist/src/internalTable/input-converter.js

@@ -14,3 +14,6 @@ "use strict";

exports.objIfExists = objIfExists;
const rawColumnToInternalColumn = (column) => (Object.assign(Object.assign(Object.assign(Object.assign({ name: column.name, title: column.title || column.name }, (0, exports.objIfExists)('color', column.color)), (0, exports.objIfExists)('maxLen', column.maxLen)), (0, exports.objIfExists)('minLen', column.minLen)), { alignment: column.alignment || table_constants_1.DEFAULT_ROW_ALIGNMENT }));
const rawColumnToInternalColumn = (column) => {
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)), (0, exports.objIfExists)('maxLen', column.maxLen)), (0, exports.objIfExists)('minLen', column.minLen)), { alignment: column.alignment || table_constants_1.DEFAULT_ROW_ALIGNMENT }));
};
exports.rawColumnToInternalColumn = rawColumnToInternalColumn;

42

dist/src/internalTable/internal-table.js

@@ -11,23 +11,2 @@ "use strict";

class TableInternal {
constructor(options) {
// default construction
this.rows = [];
this.columns = [];
this.title = undefined;
this.tableStyle = table_constants_1.DEFAULT_TABLE_STYLE;
this.filterFunction = DEFAULT_ROW_FILTER_FUNC;
this.sortFunction = DEFAULT_ROW_SORT_FUNC;
this.enabledColumns = [];
this.disabledColumns = [];
this.computedColumns = [];
this.rowSeparator = table_constants_1.DEFAULT_ROW_SEPARATOR;
this.colorMap = colored_console_line_1.DEFAULT_COLOR_MAP;
this.charLength = {};
if (options instanceof Array) {
this.initSimple(options);
}
else if (typeof options === 'object') {
this.initDetailed(options);
}
}
initSimple(columns) {

@@ -60,2 +39,23 @@ this.columns = columns.map((column) => ({

}
constructor(options) {
// default construction
this.rows = [];
this.columns = [];
this.title = undefined;
this.tableStyle = table_constants_1.DEFAULT_TABLE_STYLE;
this.filterFunction = DEFAULT_ROW_FILTER_FUNC;
this.sortFunction = DEFAULT_ROW_SORT_FUNC;
this.enabledColumns = [];
this.disabledColumns = [];
this.computedColumns = [];
this.rowSeparator = table_constants_1.DEFAULT_ROW_SEPARATOR;
this.colorMap = colored_console_line_1.DEFAULT_COLOR_MAP;
this.charLength = {};
if (options instanceof Array) {
this.initSimple(options);
}
else if (typeof options === 'object') {
this.initDetailed(options);
}
}
createColumnFromRow(text) {

@@ -62,0 +62,0 @@ const colNames = this.columns.map((col) => col.name);

import { ALIGNMENTS, COLORS } from '../utils/table-constants';
export declare type ALIGNMENT = typeof ALIGNMENTS[number];
export declare 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;

@@ -16,4 +16,4 @@ import { ColorMap } from '../utils/colored-console-line';

}
export declare type RowSortFunction = (row1: any, row2: any) => number;
export declare type RowFilterFunction = (row: any) => Boolean;
export type RowSortFunction = (row1: any, row2: any) => number;
export type RowFilterFunction = (row: any) => Boolean;
export interface ComplexOptions {

@@ -20,0 +20,0 @@ style?: TableStyleDetails;

@@ -11,7 +11,7 @@ import { ALIGNMENT, COLOR } from './common';

}
declare type TableLineDetailsKeys = 'left' | 'right' | 'mid' | 'other';
export declare type TableLineDetails = {
type TableLineDetailsKeys = 'left' | 'right' | 'mid' | 'other';
export type TableLineDetails = {
[key in TableLineDetailsKeys]: string;
};
export declare type TableStyleDetails = {
export type TableStyleDetails = {
headerTop: TableLineDetails;

@@ -18,0 +18,0 @@ headerBottom: TableLineDetails;

import { COLOR } from '../models/common';
export declare type ColorMap = {
export type ColorMap = {
[key in COLOR]?: string;

@@ -4,0 +4,0 @@ };

@@ -12,3 +12,2 @@ "use strict";

white: '\x1b[37m',
crimson: '\x1b[38m',
white_bold: '\x1b[01m',

@@ -15,0 +14,0 @@ reset: '\x1b[0m',

import { CharLengthDict } from '../models/common';
export declare const stripAnsi: (str: string) => string;
export declare const findWidthInConsole: (str: string, charLength?: CharLengthDict) => number;
export default findWidthInConsole;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findWidthInConsole = void 0;
exports.findWidthInConsole = exports.stripAnsi = void 0;
const simple_wcswidth_1 = require("simple-wcswidth");
/* eslint-disable no-control-regex */
const colorRegex = /\x1b\[\d{1,3}m/g; // \x1b[30m \x1b[305m
const colorRegex = /\x1b\[\d{1,3}(;\d{1,3})*m/g; // \x1b[30m \x1b[305m \x1b[38;5m
const stripAnsi = (str) => str.replace(colorRegex, '');
exports.stripAnsi = stripAnsi;
const findWidthInConsole = (str, charLength) => {
let strLen = 0;
str = stripAnsi(str);
str = (0, exports.stripAnsi)(str);
if (charLength) {

@@ -23,2 +24,1 @@ Object.entries(charLength).forEach(([key, value]) => {

exports.findWidthInConsole = findWidthInConsole;
exports.default = exports.findWidthInConsole;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.biggestWordInSentence = exports.limitWidth = exports.textWithPadding = void 0;
const console_utils_1 = __importDefault(require("./console-utils"));
const console_utils_1 = require("./console-utils");
// ("How are you?",center, 20) => " How are you? "
// ("How are you?",right, 20) => " How are you?"
const textWithPadding = (text, alignment, columnLen, charLength) => {
const curTextSize = (0, console_utils_1.default)(text, charLength);
const curTextSize = (0, console_utils_1.findWidthInConsole)(text, charLength);
// alignments for center padding case

@@ -41,3 +38,3 @@ const leftPadding = Math.floor((columnLen - curTextSize) / 2);

spaceSeparatedStrings.forEach((strWithoutSpace) => {
const consoleWidth = (0, console_utils_1.default)(strWithoutSpace, charLength);
const consoleWidth = (0, console_utils_1.findWidthInConsole)(strWithoutSpace, charLength);
if (cnt + consoleWidth <= width) {

@@ -60,3 +57,3 @@ cnt += consoleWidth + 1; // 1 for the space

.split(' ')
.reduce((a, b) => Math.max(a, (0, console_utils_1.default)(b, charLength)), 0);
.reduce((a, b) => Math.max(a, (0, console_utils_1.findWidthInConsole)(b, charLength)), 0);
exports.biggestWordInSentence = biggestWordInSentence;

@@ -49,3 +49,2 @@ "use strict";

'cyan',
'crimson',
'white_bold',

@@ -52,0 +51,0 @@ 'reset',

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getWidthLimitedColumnsArray = exports.createHeaderAsRow = exports.renderTableHorizontalBorders = exports.findLenOfColumn = exports.createRow = exports.createColumFromComputedColumn = exports.createColumFromOnlyName = exports.createTableHorizontalBorders = exports.convertRawRowOptionsToStandard = exports.cellText = void 0;
const input_converter_1 = require("../internalTable/input-converter");
const console_utils_1 = __importDefault(require("./console-utils"));
const console_utils_1 = require("./console-utils");
const string_utils_1 = require("./string-utils");

@@ -45,3 +42,6 @@ const table_constants_1 = require("./table-constants");

exports.createColumFromOnlyName = createColumFromOnlyName;
const createColumFromComputedColumn = (column) => (Object.assign(Object.assign(Object.assign(Object.assign({ name: column.name, title: column.title || column.name }, (0, input_converter_1.objIfExists)('color', column.color)), (0, input_converter_1.objIfExists)('maxLen', column.maxLen)), (0, input_converter_1.objIfExists)('minLen', column.minLen)), { alignment: column.alignment || table_constants_1.DEFAULT_ROW_ALIGNMENT }));
const createColumFromComputedColumn = (column) => {
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, input_converter_1.objIfExists)('color', column.color)), (0, input_converter_1.objIfExists)('maxLen', column.maxLen)), (0, input_converter_1.objIfExists)('minLen', column.minLen)), { alignment: column.alignment || table_constants_1.DEFAULT_ROW_ALIGNMENT }));
};
exports.createColumFromComputedColumn = createColumFromComputedColumn;

@@ -65,5 +65,5 @@ const createRow = (color, text, separator) => ({

}
length = max(length, (0, console_utils_1.default)(columnTitle, charLength));
length = max(length, (0, console_utils_1.findWidthInConsole)(columnTitle, charLength));
rows.forEach((row) => {
length = max(length, (0, console_utils_1.default)((0, exports.cellText)(row.text[columnId]), charLength));
length = max(length, (0, console_utils_1.findWidthInConsole)((0, exports.cellText)(row.text[columnId]), charLength));
});

@@ -70,0 +70,0 @@ return length;

{
"name": "console-table-printer",
"version": "2.11.1",
"version": "2.11.2",
"repository": "github:ayonious/console-table-printer",

@@ -28,20 +28,20 @@ "description": "Printing pretty tables on console log",

"devDependencies": {
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@types/jest": "^28.1.8",
"@typescript-eslint/eslint-plugin": "^5.34.0",
"@typescript-eslint/parser": "^5.34.0",
"@types/jest": "^29.5.2",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"chalk": "^4.1.2",
"eslint": "^8.22.0",
"eslint": "^8.44.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.1",
"jest": "^28.1.3",
"prettier": "^2.7.1",
"husky": "^8.0.3",
"jest": "^29.5.0",
"prettier": "^2.8.8",
"pretty-quick": "^3.1.3",
"semantic-release": "^19.0.5",
"ts-jest": "^28.0.8",
"typescript": "^4.7.4"
"semantic-release": "^21.0.6",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
},

@@ -48,0 +48,0 @@ "homepage": "https://console-table.netlify.app",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc