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.5.9 to 2.6.0

.github/ISSUE_TEMPLATE.md

113

adapters/automattic-cli-table.js

@@ -1,72 +0,69 @@

var Public = require('../src/public.js');
var Factory = require('../src/factory.js');
var Table = function(options){
options = options || {};
options = options || {};
options.adapter = "automattic";
//translations
//header
var header = [];
if(options.head && options.head instanceof Array){
options.head.forEach(function(val){
header.push({
value : val
});
});
}
//translations
//header
var header = [];
if(options.head && options.head instanceof Array){
options.head.forEach(function(val){
header.push({
value : val
});
});
}
//colWidths
if(options.colWidths){
options.colWidths.forEach(function(val,i){
header[i].width = val;
});
}
//colWidths
if(options.colWidths){
options.colWidths.forEach(function(val,i){
header[i].width = val;
});
}
//colAligns
if(options.colAligns){
options.colAligns.forEach(function(val,i){
header[i].align = val;
header[i].headerAlign = val;
});
}
//colAligns
if(options.colAligns){
options.colAligns.forEach(function(val,i){
header[i].align = val;
header[i].headerAlign = val;
});
}
//style
options.style = options.style || {};
//style
options.style = options.style || {};
//style - padding
if(options.style['padding-left']){
options.paddingLeft = options.style['padding-left'];
}
if(options.style['padding-right']){
options.paddingRight = options.style['padding-right'];
}
//style - colors
if(options.style.head && options.style.head instanceof Array){
options.headerColor = options.style.head[0];
}
//style - padding
if(options.style['padding-left']){
options.paddingLeft = options.style['padding-left'];
}
if(options.style['padding-right']){
options.paddingRight = options.style['padding-right'];
}
//style - colors
if(options.style.head && options.style.head instanceof Array){
options.headerColor = options.style.head[0];
}
if(options.style.body && options.style.body instanceof Array){
options.color = options.style.body[0];
}
//style - compact
if(options.style.compact){
options.compact = true;
}
if(options.style.body && options.style.body instanceof Array){
options.color = options.style.body[0];
}
//style - compact
if(options.style.compact){
options.compact = true;
}
//@todo style - border color
//inherited from prototype
this.setup(header,[],[],options);
//inherited from prototype
this.toString = this.render.bind(this);
//@todo style - border color
//inherited from prototype
let t = Factory(header,[],[],options);
t.toString = t.render;
return t;
}
Table.prototype.__proto__ = Public;
module.exports = Table;
#!/usr/bin/env node
let csv = require('csv');
let yargs = require('yargs');
yargs.epilog('Copyight github.com/tecfu 2017');
yargs.epilog('Copyight github.com/tecfu 2018');
yargs.option('csv-delimiter',{

@@ -24,2 +24,4 @@ describe:'Set the field delimiter. One character only.',

});
//run help only at the end
yargs = yargs.help('h').argv;

@@ -39,5 +41,5 @@ let Chalk = require('chalk');

switch(true){
case(typeof yargs.argv.format === 'undefined'):
case(typeof yargs.format === 'undefined'):
break;
case(yargs.argv.format.toString().match(/json/i) !== null):
case(yargs.format.toString().match(/json/i) !== null):
dataFormat = 'json';

@@ -50,6 +52,6 @@ break;

let options = {};
Object.keys(yargs.argv).forEach(function(key){
Object.keys(yargs).forEach(function(key){
let keyParts = key.split('-');
if(keyParts[0]==='options'){
options[keyParts[1]]=yargs.argv[key];
options[keyParts[1]]=yargs[key];
}

@@ -59,3 +61,3 @@ });

//look for header-n-*
//Object.keys(yargs.argv).forEach(function(key){
//Object.keys(yargs).forEach(function(key){
// let keyParts = key.split('-');

@@ -68,3 +70,3 @@ // if(keyParts[0] === 'header'){

// }
// header[column][keyParts[2]] = yargs.argv[key];
// header[column][keyParts[2]] = yargs[key];
// }

@@ -83,4 +85,5 @@ //});

let Table = require('../src/public.js');
let t1 = Table.setup(header,body,options);
let Table = require('../src/factory.js');
options.terminalAdapter = true;
let t1 = Table(header,body,options);

@@ -132,5 +135,5 @@ //hide cursor

let formatterOptions = {};
Object.keys(yargs.argv).forEach(function(key){
if(key.slice(0,4) === 'csv-' && typeof(yargs.argv[key]) !== 'undefined'){
formatterOptions[key.slice(4)] = yargs.argv[key];
Object.keys(yargs).forEach(function(key){
if(key.slice(0,4) === 'csv-' && typeof(yargs[key]) !== 'undefined'){
formatterOptions[key.slice(4)] = yargs[key];
}

@@ -173,4 +176,1 @@ });

});
//run help only at the end
yargs.argv = yargs.help('h').argv;

@@ -84,3 +84,3 @@ var Chalk = require('chalk');

t1.push(
t4.push(
["chocolate cake",4.65,"no"]

@@ -102,3 +102,3 @@ );

t1.push(
t5.push(
["chocolate cake",5.65,"no"]

@@ -105,0 +105,0 @@ );

@@ -42,3 +42,3 @@ /**

command: function () {
var cmd = 'browserify --standalone=TtyTable '+_ignore+' -r ./src/default-adapter.js > ./dist/<%= pkg.name %>.js -t [ babelify --presets [ es2015 babili] ] -p [ browserify-banner --template "'+banner+'"]';
var cmd = 'browserify --standalone=TtyTable '+_ignore+' -r ./adapters/default-adapter.js > ./dist/<%= pkg.name %>.js -t [ babelify --presets [ es2015 babili] ] -p [ browserify-banner --template "'+banner+'"]';
return cmd;

@@ -49,3 +49,3 @@ }

command: function () {
var cmd = 'browserify --debug --standalone=TtyTable '+_ignore+' -r ./src/default-adapter.js > ./dist/<%= pkg.name %>.devel.js -t [ babelify --presets [ es2015 babili] ]';
var cmd = 'browserify --debug --standalone=TtyTable '+_ignore+' -r ./adapters/default-adapter.js > ./dist/<%= pkg.name %>.devel.js -t [ babelify --presets [ es2015 babili] ]';
return cmd;

@@ -56,3 +56,3 @@ }

command: function () {
var cmd = 'browserify '+_ignore+' -r ./src/default-adapter.js:<%= pkg.name %> > ./dist/<%= pkg.name %>.bundle.js -t [ babelify --presets [ es2015 babili] ]';
var cmd = 'browserify '+_ignore+' -r ./adapters/default-adapter.js:<%= pkg.name %> > ./dist/<%= pkg.name %>.bundle.js -t [ babelify --presets [ es2015 babili] ]';
return cmd;

@@ -63,3 +63,3 @@ }

command: function () {
var cmd = 'browserify --debug '+_ignore+' -r ./src/default-adapter.js:<%= pkg.name %> > ./dist/<%= pkg.name %>.bundle.devel.js -t [ babelify --presets [ es2015 babili] ]';
var cmd = 'browserify --debug '+_ignore+' -r ./adapters/default-adapter.js:<%= pkg.name %> > ./dist/<%= pkg.name %>.bundle.devel.js -t [ babelify --presets [ es2015 babili] ]';
return cmd;

@@ -92,6 +92,9 @@ }

files: ['**/*.js'],
tasks: ['shell:generate-vim-tags-file'],
tasks: [
'shell:generate-vim-tags-file',
'mochaTest:test'
],
options: {
spawn: true,
reload: false
livereload: true //defaults to port 35729
}

@@ -98,0 +101,0 @@ }

{
"name": "tty-table",
"version": "2.5.9",
"version": "2.6.0",
"description": "Command line table generator.",

@@ -5,0 +5,0 @@ "main": "src/main.js",

let Config = {
borderCharacters : [
[
{v: " ", l: " ", j: " ", h: " ", r: " "},
{v: " ", l: " ", j: " ", h: " ", r: " "},
{v: " ", l: " ", j: " ", h: " ", r: " "}
borderCharacters : [
[
{v: " ", l: " ", j: " ", h: " ", r: " "},
{v: " ", l: " ", j: " ", h: " ", r: " "},
{v: " ", l: " ", j: " ", h: " ", r: " "}
],
[
{v: "│", l: "┌", j: "┬", h: "─", r: "┐"},
{v: "│", l: "├", j: "┼", h: "─", r: "┤"},
{v: "│", l: "└", j: "┴", h: "─", r: "┘"}
],
[
{v: "|", l: "+", j: "+", h: "-", r: "+"},
{v: "|", l: "+", j: "+", h: "-", r: "+"},
{v: "|", l: "+", j: "+", h: "-", r: "+"}
]
],
[
{v: "│", l: "┌", j: "┬", h: "─", r: "┐"},
{v: "│", l: "├", j: "┼", h: "─", r: "┤"},
{v: "│", l: "└", j: "┴", h: "─", r: "┘"}
],
[
{v: "|", l: "+", j: "+", h: "-", r: "+"},
{v: "|", l: "+", j: "+", h: "-", r: "+"},
{v: "|", l: "+", j: "+", h: "-", r: "+"}
]
],
align : "center",
borderColor : null,
borderStyle : 1,
color : false,
compact : false,
defaultErrorValue : " ERROR! ",
defaultValue : " ? ",
errorOnNull : false,
footerAlign : "center",
footerColor : false,
formatter : null,
headerAlign : "center",
headerColor : "yellow",
marginLeft : 2,
marginTop : 1,
paddingBottom : 0,
paddingLeft : 1,
paddingRight : 1,
paddingTop : 0,
tableType : null,
truncate: false,
width : "auto",
GUTTER : 1, //undocumented
columnSettings : [],
headerEmpty : false,
//save so cell options can be merged into column options
table : {
body : '',
columnInnerWidths : [],
columnWidths : [],
columns : [],
footer : '',
header : '', //post-rendered strings.
height : 0,
typeLocked : false //once a table type is selected can't switch
}
align : "center",
borderColor : null,
borderStyle : 1,
color : false,
compact : false,
defaultErrorValue : " ERROR! ",
defaultValue : " ? ",
errorOnNull : false,
footerAlign : "center",
footerColor : false,
formatter : null,
headerAlign : "center",
headerColor : "yellow",
marginLeft : 2,
marginTop : 1,
paddingBottom : 0,
paddingLeft : 1,
paddingRight : 1,
paddingTop : 0,
tableType : null,
truncate: false,
width : "auto",
GUTTER : 1, //undocumented
columnSettings : [],
headerEmpty : false,
//save so cell options can be merged into column options
table : {
body : '',
columnInnerWidths : [],
columnWidths : [],
columns : [],
footer : '',
header : '', //post-rendered strings.
height : 0,
typeLocked : false //once a table type is selected can't switch
}
};
module.exports = Config;

@@ -68,3 +68,3 @@ let StripAnsi = require("strip-ansi");

config.GUTTER;
switch(true){

@@ -71,0 +71,0 @@ //no wrap, truncate

@@ -5,7 +5,7 @@ require('use-strict');

//called directly in terminal
require('./terminal-adapter.js');
require('./../adapters/terminal-adapter.js');
}
else{
//called as a module
module.exports = require('./default-adapter.js');
module.exports = require('./../adapters/default-adapter.js');
}

@@ -29,6 +29,10 @@ let Merge = require("merge");

if(!global.columnWidths){
global.columnWidths = config.table.columnWidths = Format.getColumnWidths(config,data);
global.columnWidths = {};
}
if(global.columnWidths[config.tableId]){
config.table.columnWidths = global.columnWidths[config.tableId];
}
else{
config.table.columnWidths = global.columnWidths;
global.columnWidths[config.tableId] = config.table.columnWidths = Format.getColumnWidths(config,data);
}

@@ -124,11 +128,7 @@

output += borders[2];
//remove all rows in prototype array
this.splice(0,this.length);
let finalOutput = Array(config.marginTop + 1).join('\n') + output;
//record the height of the output
this.height = finalOutput.split(/\r\n|\r|\n/).length;
config.height = finalOutput.split(/\r\n|\r|\n/).length;
return finalOutput;

@@ -138,3 +138,3 @@ };

const buildRow = function(config,row,rowType){
let minRowHeight = 0;

@@ -207,3 +207,3 @@

});
return lines;

@@ -213,4 +213,5 @@ }

Render.buildCell = function(config,cell,columnIndex,rowType){
let cellValue,
cellOptions = Merge(true,config,
let cellValue;
let cellOptions = Merge(true,{},config,
(rowType === 'body') ?

@@ -217,0 +218,0 @@ config.columnSettings[columnIndex] : {}, //ignore columnSettings for footer

@@ -24,29 +24,18 @@

┌──────┬─────────────────────┬─────────────────────────┬─────────────────┐
│ v0.1 │ Testing something │ rauchg@gmail.com │ 7 minutes ago │
│ │ cool │ │ │
└──────┴─────────────────────┴─────────────────────────┴─────────────────┘
┌──────┬────────────────────────┬──────────────────┬───────────────┐
│ v0.1 │ Testing something cool │ rauchg@gmail.com │ 7 minutes ago │
└──────┴────────────────────────┴──────────────────┴───────────────┘
┌──────┬─────────────────────┬─────────────────────────┬─────────────────┐
│ Some │ Some Value │ ? │ ? │
│ Key │ │ │ │
├──────┼─────────────────────┼─────────────────────────┼─────────────────┤
│ Anot │ And its │ ? │ ? │
│ her │ corresponding │ │ │
│ much │ longer value │ │ │
│ long │ │ │ │
│ er │ │ │ │
│ key │ │ │ │
└──────┴─────────────────────┴─────────────────────────┴─────────────────┘
┌─────────────────────────┬────────────────────────────────────┐
│ Some Key │ Some Value │
├─────────────────────────┼────────────────────────────────────┤
│ Another much longer key │ And its corresponding longer value │
└─────────────────────────┴────────────────────────────────────┘
┌──────┬─────────────────────┬─────────────────────────┬─────────────────┐
│ │ Header #1 │ Header #2 │ │
├──────┼─────────────────────┼─────────────────────────┼─────────────────┤
│ Head │ Value 1 │ Value 2 │ ? │
│ er │ │ │ │
│ #3 │ │ │ │
├──────┼─────────────────────┼─────────────────────────┼─────────────────┤
│ Head │ Value 3 │ Value 4 │ ? │
│ er │ │ │ │
│ #4 │ │ │ │
└──────┴─────────────────────┴─────────────────────────┴─────────────────┘
┌───────────┬───────────┬───────────┐
│ │ Header #1 │ Header #2 │
├───────────┼───────────┼───────────┤
│ Header #3 │ Value 1 │ Value 2 │
├───────────┼───────────┼───────────┤
│ Header #4 │ Value 3 │ Value 4 │
└───────────┴───────────┴───────────┘

@@ -40,8 +40,8 @@

┌──────────────────────────────┬──────────┬───────────────┐
│ name │ price │ │
├──────────────────────────────┼──────────┼───────────────┤
│ apple mac │ 92.5 │ ? │
├──────────────────────────────┼──────────┼───────────────┤
│ ibm │ 120.15 │ ? │
└──────────────────────────────┴──────────┴───────────────┘
┌──────────────────────────────┬──────────────────────────────┐
│ name │ price │
├──────────────────────────────┼──────────────────────────────┤
│ apple mac │ 92.5 │
├──────────────────────────────┼──────────────────────────────┤
│ ibm │ 120.15 │
└──────────────────────────────┴──────────────────────────────┘

@@ -20,11 +20,12 @@

+---------------------------+------+-----+
| 项目 | 价 | 有 |
| | 格 | 机 |
+---------------------------+------+-----+
| abc | ? | ? |
+---------------------------+------+-----+
| abć | ? | ? |
+---------------------------+------+-----+
| ab한 | ? | ? |
+---------------------------+------+-----+
+-------+--------+--------+
| 项 | 价格 | 有机 |
| 目 | | |
+-------+--------+--------+
| abc | ? | ? |
+-------+--------+--------+
| abć | ? | ? |
+-------+--------+--------+
| ab | ? | ? |
| 한 | | |
+-------+--------+--------+

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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