Comparing version 2.5.7 to 2.5.8
@@ -127,1 +127,20 @@ var Table = require('../'); | ||
console.log(str2); | ||
//template literals | ||
let header3 = [ | ||
{ value: 'name', width: 30, headerAlign: 'left' }, | ||
{ value: 'price', width: 30, headerAlign: 'left' } | ||
]; | ||
const opts = { | ||
align: 'left' | ||
}; | ||
const data = [ | ||
[`apple ${chalk.red("mac")}`,92.50], | ||
["ibm",120.15] | ||
] | ||
let t3 = Table(header3,data, opts); | ||
console.log(t3.render()); |
@@ -35,19 +35,32 @@ var Table = require('../'); | ||
//var rows = [ | ||
// "abc", | ||
// "abć", | ||
// "ab한" | ||
//]; | ||
// | ||
//var t2 = Table(header,rows,{ | ||
// borderStyle : 2, | ||
// paddingBottom : 0, | ||
// paddingLeft: 2, | ||
// paddingRight: 2, | ||
// headerAlign : "right", | ||
// align : "center", | ||
// color : "white" | ||
//}); | ||
// | ||
//str2 = t2.render(); | ||
//console.log(str2); | ||
var header2 = [ | ||
{ | ||
value : "项目", | ||
}, | ||
{ | ||
value : "价格", | ||
}, | ||
{ | ||
value : "有机", | ||
} | ||
]; | ||
var rows2 = [ | ||
["abc"], | ||
["abć"], | ||
["ab한"] | ||
]; | ||
var t2 = Table(header2,rows2,{ | ||
borderStyle : 2, | ||
paddingBottom : 0, | ||
paddingLeft: 2, | ||
paddingRight: 2, | ||
headerAlign : "right", | ||
align : "center", | ||
color : "white" | ||
}); | ||
str2 = t2.render(); | ||
console.log(str2); |
{ | ||
"name": "tty-table", | ||
"version": "2.5.7", | ||
"version": "2.5.8", | ||
"description": "Command line table generator.", | ||
@@ -5,0 +5,0 @@ "main": "src/main.js", |
@@ -1,2 +0,2 @@ | ||
//let StripAnsi = require("strip-ansi"); | ||
let StripAnsi = require("strip-ansi"); | ||
//let Wrap = require("word-wrap"); | ||
@@ -9,3 +9,3 @@ let Wrap = require("smartwrap"); | ||
//return StripAnsi(line.replace(/[^\x00-\xff]/g,'XX')).length; | ||
return Wcwidth(line); | ||
return Wcwidth(StripAnsi(line)); | ||
} | ||
@@ -84,3 +84,4 @@ | ||
//string has wide characters | ||
case(string.length < Format.calculateLength(string)): | ||
case(/[\uD800-\uDFFF]/.test(string)): | ||
//case(string.length < Format.calculateLength(string)): | ||
string = Format.handleWideChars( | ||
@@ -87,0 +88,0 @@ string, |
@@ -39,1 +39,9 @@ | ||
└──────────────────────────────┴──────────┴───────────────┘ | ||
┌──────────────────────────────┬──────────┬───────────────┐ | ||
│[33m name [39m│[33m price [39m│ │ | ||
├──────────────────────────────┼──────────┼───────────────┤ | ||
│ apple [31mmac [39m│ 92.5 │[32m[37m[41m ? [49m[32m[39m│ | ||
├──────────────────────────────┼──────────┼───────────────┤ | ||
│ ibm │ 120.15 │[32m[37m[41m ? [49m[32m[39m│ | ||
└──────────────────────────────┴──────────┴───────────────┘ |
┌───────────────────────────┬──────┬─────┐ | ||
│[33m 项目 [39m│[33m 价格 [39m│[33m 有 [39m│ | ||
│ │ │[33m 机 [39m│ | ||
├───────────────────────────┼──────┼─────┤ | ||
@@ -15,3 +16,15 @@ │[37m 汉堡包 [39m│[37m 2.5 [39m│[37m[32m[37m[41m ? [49m[32m[37m[39m│ | ||
├───────────────────────────┼──────┼─────┤ | ||
│[37m 意大利粉, 火腿, 意大利干 [39m│[37m 3.75 [39m│[37m no [39m│ | ||
│[37m 意大利粉, 火腿, [39m│[37m 3.75 [39m│[37m no [39m│ | ||
│[37m 意大利干酪 [39m│ │ │ | ||
└───────────────────────────┴──────┴─────┘ | ||
+---------------------------+------+-----+ | ||
|[33m 项目 [39m|[33m 价 [39m|[33m 有 [39m| | ||
| |[33m 格 [39m|[33m 机 [39m| | ||
+---------------------------+------+-----+ | ||
|[37m abc [39m|[37m[32m[37m[41m ? [49m[32m[37m[39m|[37m[32m[37m[41m ? [49m[32m[37m[39m| | ||
+---------------------------+------+-----+ | ||
|[37m abć [39m|[37m[32m[37m[41m ? [49m[32m[37m[39m|[37m[32m[37m[41m ? [49m[32m[37m[39m| | ||
+---------------------------+------+-----+ | ||
|[37m ab한 [39m|[37m[32m[37m[41m ? [49m[32m[37m[39m|[37m[32m[37m[41m ? [49m[32m[37m[39m| | ||
+---------------------------+------+-----+ |
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
1020176
17375