Comparing version 2.8.8 to 2.8.9
{ | ||
"name": "tty-table", | ||
"version": "2.8.8", | ||
"version": "2.8.9", | ||
"description": "Node cli table", | ||
@@ -54,3 +54,3 @@ "main": "src/main.js", | ||
"csv": "^5.3.1", | ||
"smartwrap": "^1.2.1", | ||
"smartwrap": "^1.2.2", | ||
"strip-ansi": "^6.0.0", | ||
@@ -57,0 +57,0 @@ "wcwidth": "^1.0.1", |
@@ -180,3 +180,3 @@ # tty-table 电传打字台 | ||
| compact | <code>boolean</code> | default: false Removes horizontal lines when true. | | ||
| defaultErrorValue | <code>mixed</code> | default: 'ERROR!' | | ||
| defaultErrorValue | <code>mixed</code> | default: '�' | | ||
| defaultValue | <code>mixed</code> | default: '?' | | ||
@@ -183,0 +183,0 @@ | errorOnNull | <code>boolean</code> | default: false | |
@@ -29,4 +29,5 @@ const defaults = { | ||
compact: false, | ||
defaultErrorValue: "[32m[37m[41m ERROR! [49m[32m[39m", | ||
defaultValue: "[32m[37m[41m ? [49m[32m[39m", | ||
defaultErrorValue: "�", | ||
//defaultValue: "\u001b[31m?\u001b[39m", | ||
defaultValue: "[32m[37m[41m ?[49m[32m[39m", | ||
errorOnNull: false, | ||
@@ -33,0 +34,0 @@ footerAlign: "center", |
@@ -63,15 +63,6 @@ const StripAnsi = require("strip-ansi") | ||
switch(true) { | ||
//no wrap, truncate | ||
case(typeof config.truncate === "string"): | ||
string = Format.handleTruncatedValue(string, cellOptions, innerWidth) | ||
break | ||
//string has wide characters | ||
case(/[\uD800-\uDFFF]/.test(string)): | ||
//case(string.length < Format.calculateLength(string)): | ||
string = Format.handleWideChars(string, cellOptions, innerWidth) | ||
break | ||
//string does not have wide characters | ||
default: | ||
string = Format.handleNonWideChars(string, cellOptions, innerWidth) | ||
if(typeof config.truncate === "string") { | ||
string = Format.truncate(string, cellOptions, innerWidth) | ||
} else { | ||
string = Format.wrap(string, cellOptions, innerWidth) | ||
} | ||
@@ -120,3 +111,3 @@ | ||
Format.handleTruncatedValue = (string, cellOptions, maxWidth) => { | ||
Format.truncate = (string, cellOptions, maxWidth) => { | ||
const stringWidth = Wcwidth(string) | ||
@@ -134,27 +125,8 @@ if(maxWidth < stringWidth) { | ||
Format.handleWideChars = (string, cellOptions, innerWidth) => { | ||
let count = 0 | ||
let start = 0 | ||
let characters = string.split("") | ||
let outstring = characters.reduce((prev, cellValue, i) => { | ||
count += Format.calculateLength(cellValue) | ||
if (count > innerWidth) { | ||
prev.push(string.slice(start, i)) | ||
start = i | ||
count = 0 | ||
} else if (characters.length === i + 1) { | ||
prev.push(string.slice(start)) | ||
} | ||
return prev | ||
}, []).join("\n") | ||
return outstring | ||
} | ||
Format.handleNonWideChars = (string, cellOptions, innerWidth) => { | ||
Format.wrap = (string, cellOptions, innerWidth) => { | ||
let outstring = Smartwrap(string, { | ||
width: innerWidth, | ||
errorChar: cellOptions.defaultErrorValue, | ||
minWidth: 1, | ||
trim: true//, | ||
trim: true, | ||
width: innerWidth | ||
//indent : '', | ||
@@ -208,4 +180,5 @@ //cut : true | ||
let result | ||
switch(true) { | ||
//column width specified in header | ||
//column width specified in header | ||
case(typeof column === "object" && typeof column.width === "number"): | ||
@@ -212,0 +185,0 @@ result = column.width |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42704
962
Updatedsmartwrap@^1.2.2