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 4.1.0 to 4.1.1

3

package.json
{
"name": "tty-table",
"version": "4.1.0",
"version": "4.1.1",
"description": "Node cli table",

@@ -57,2 +57,3 @@ "main": "src/main.js",

"csv": "^5.3.1",
"kleur": "^3.0.3",
"smartwrap": "^2.0.1",

@@ -59,0 +60,0 @@ "strip-ansi": "^6.0.0",

@@ -78,5 +78,5 @@ # tty-table 端子台

| formatter | <code>function(cellValue, columnIndex, rowIndex, rowData, inputData</code> | Runs a callback on each cell value in the parent column. <br/>Please note that fat arrow functions `() => {}` don't support scope overrides, and this feature won't work correctly within them. |
| @formatter configure | <code>function(object)</code> | Configure cell properties. For example: <br/>`this.configure({ truncate: false, align: "left" })` |
| @formatter resetStyle | <code>function(cellValue)</code> | Removes ANSI escape sequences. For example: <br/>`this.resetStyle(" myText") // "myText"`<br/>[More here.](https://github.com/tecfu/tty-table/blob/master/examples/truncated-lines.js#L100-L110)) |
| @formatter style | <code>function(cellValue, effect)</code> | Style cell value. For example: <br/>`this.style("mytext", "bold", "green", "underline")`<br/>For a full list of options, see: [chalk](https://github.com/chalk/chalk). |
| @formatter configure | <code>function(object)</code> | Configure cell properties. For example: <br/>`this.configure({ truncate: false, align: "left" })` [More here](https://github.com/tecfu/tty-table/blob/master/examples/truncated-lines.js#L100-L110). |
| @formatter resetStyle | <code>function(cellValue)</code> | Removes ANSI escape sequences. For example: <br/>`this.resetStyle(" myText") // "myText"`<br/> |
| @formatter style | <code>function(cellValue, effect)</code> | Style cell value. For example: <br/>`this.style("mytext", "bold", "green", "underline")`<br/>For a full list of options in the terminal: [chalk](https://github.com/chalk/chalk). For a full list of options in the browser: [chalk](https://github.com/lukeed/kleur)|
| headerAlign | <code>string</code> | default: "center" |

@@ -83,0 +83,0 @@ | headerColor | <code>string</code> | default: terminal's default color |

@@ -41,3 +41,2 @@ // @TODO split defaults into table and cell settings

headerColor: "yellow",
headerTruncate: false,
isNull: false, // undocumented cell setting

@@ -44,0 +43,0 @@ marginLeft: 2,

@@ -147,5 +147,3 @@ const stripAnsi = require("strip-ansi")

const truncKey = (rowType === 'header') ? "headerTruncate" : "truncate"
if (typeof config[truncKey] === "string") {
if (typeof config.truncate === "string") {
string = exports.truncate(string, cellOptions, innerWidth)

@@ -196,3 +194,3 @@ } else {

module.exports.truncate = (string, cellOptions, maxWidth, rowType) => {
module.exports.truncate = (string, cellOptions, maxWidth) => {
const stringWidth = wcwidth(string)

@@ -202,8 +200,7 @@

// @TODO give user option to decide if they want to break words on wrapping
let truncKey = (rowType === 'header') ? "headerTruncate" : "truncate"
string = smartwrap(string, {
width: maxWidth - cellOptions[truncKey].length,
width: maxWidth - cellOptions.truncate.length,
breakword: true
}).split("\n")[0]
string = string + cellOptions[truncKey]
string = string + cellOptions.truncate
}

@@ -210,0 +207,0 @@

@@ -214,6 +214,3 @@ const Style = require("./style.js")

const cellOptions = Object.assign(
{
reset: false,
rowType: rowType
},
{ reset: false },
config,

@@ -220,0 +217,0 @@ (rowType === "body") ? config.columnSettings[columnIndex] : {}, // ignore columnSettings for footer

const chalk = require("chalk")
const kleur = require("kleur")
// user kleur if we are in the browser
const colorLib = (process && process.stdout) ? chalk : kleur
const stripAnsi = require("strip-ansi")

@@ -6,3 +11,3 @@

const out = colors.reduce(function (input, color) {
return chalk[color](input)
return colorLib[color](input)
}, str)

@@ -20,3 +25,3 @@ return out

const coded = colors.reduce((input, color) => {
return chalk[color](input)
return colorLib[color](input)
}, current)

@@ -23,0 +28,0 @@ return prev + coded

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