Socket
Socket
Sign inDemoInstall

tty-table

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tty-table - npm Package Compare versions

Comparing version 2.8.8 to 2.8.9

4

package.json
{
"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: " ERROR! ",
defaultValue: " ? ",
defaultErrorValue: "�",
//defaultValue: "\u001b[31m?\u001b[39m",
defaultValue: " ?",
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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc