Socket
Socket
Sign inDemoInstall

tty-table

Package Overview
Dependencies
44
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.5 to 2.3.0

.editorconfig

20

examples/auttomatic-cli-table-tests-output.txt

@@ -12,16 +12,15 @@

┌─────┬────────────────────┬────────────────────────┬────────────────┐
│ Rel │ Change │ By │ When │
│ Re │ Change │ By │ When │
│ l │ │ │ │
├─────┼────────────────────┼────────────────────────┼────────────────┤
│v0.1 │ Testing │ rauchg@gmail.com │ 7 minutes │
│ │ something cool │ │ ago │
│v0.1 │ Testing │ rauchg@gmail.com │ 8 minutes │
│ │ something cool │ │ ago │
│ v0 │ Testing │ rauchg@gmail.com │ 7 minutes │
│ .1 │ something cool │ │ ago │
│ v0 │ Testing │ rauchg@gmail.com │ 8 minutes │
│ .1 │ something cool │ │ ago │
├─────┼────────────────────┼────────────────────────┼────────────────┤
│v0.1 │ Testing │ rauchg@gmail.com │ 8 minutes │
│ │ something cool │ │ ago │
│ v0 │ Testing │ rauchg@gmail.com │ 8 minutes │
│ .1 │ something cool │ │ ago │
└─────┴────────────────────┴────────────────────────┴────────────────┘
┌───────────────────┬───────────────────┬───────────────────┬───────────────────┐

@@ -32,3 +31,2 @@ │ v0.1 │ Testing something │ rauchg@gmail.com │ 7 minutes ago │

┌───────────────────┬───────────────────┐

@@ -42,3 +40,2 @@ │ Some Key │ Some Value │

┌───────────────────┬───────────────────┬───────────────────┐

@@ -51,2 +48,1 @@ │ │ Header #1 │ Header #2 │

└───────────────────┴───────────────────┴───────────────────┘

19

examples/data/streamer.js
var baseline = {
"aapl" : 92,
"ibm" : 120
"ibm" : 120,
"wmt" : 68,
"abx" : 13,
"msft" : 35
};
var last = {};
setInterval(function(){
// //Add imaginary ticker
// var newTicker = Math.random().toString(36).substring(7);
// baseline[newTicker] = Math.random();
//
// //Remove a random ticker
// var keys = Object.keys(baseline);
// var random = Math.floor(Math.random() * keys.length) + 0;
// delete baseline[keys[random]];
var array = [];
for(var i in baseline){

@@ -12,2 +28,3 @@ baseline[i] = (baseline[i] + ((Math.random() > .5) ? .01 : -.01)).toFixed(2)*1;

}
var string = JSON.stringify(array);

@@ -14,0 +31,0 @@ console.log(string);

@@ -24,3 +24,2 @@

┌─────────────────────────────┬─────────┬──────────────┐

@@ -45,2 +44,1 @@ │ item │ price │ Is organic? │

└─────────────────────────────┴─────────┴──────────────┘

@@ -28,3 +28,2 @@

┌───────────────────┬─────────┬─────────┐

@@ -51,2 +50,1 @@ │ item │ price │ organic │

└───────────────────┴─────────┴─────────┘

@@ -8,3 +8,2 @@

┌─────────┬─────────┬─────────┐

@@ -16,3 +15,2 @@ │ item │ price │ organic │

┌─────────┬─────────┬─────────┐

@@ -23,2 +21,1 @@ │ item │ price │ or... │

└─────────┴─────────┴─────────┘

@@ -19,2 +19,1 @@

└───────────────────┴───────────────────┴───────────────────┘

@@ -5,4 +5,2 @@ /**

*/
module.exports = function(grunt) {

@@ -13,2 +11,4 @@

var banner = '/** \n<%= pkg.name %>: <%= pkg.description %> \nVersion: <%= pkg.version %> \nBuilt: <%= grunt.template.today("yyyy-mm-dd") %> <%= options.timestamp %>\nAuthor: <%= pkg.author %> \n*/\n';
// Project configuration.

@@ -41,29 +41,2 @@ grunt.initConfig({

uglify: {
"min": {
options: {
banner: '/** \n<%= pkg.name %>: <%= pkg.description %> \nVersion: <%= pkg.version %> \nBuilt: <%= grunt.template.today("yyyy-mm-dd") %> <%= options.timestamp %>\nAuthor: <%= pkg.author %> \n*/\n'
,mangle : true
,compress : true
,drop_debugger : false
,wrap : true
}
,files: {
'dist/<%= pkg.name %>.min.js': 'dist/<%= pkg.name %>.js',
}
},
"bundle-min": {
options: {
banner: '/** \n<%= pkg.name %>: <%= pkg.description %> \nVersion: <%= pkg.version %> \nBuilt: <%= grunt.template.today("yyyy-mm-dd") %> <%= options.timestamp %>\nAuthor: <%= pkg.author %> \n*/\n'
,mangle : true
,compress : true
,drop_debugger : false
,wrap : true
}
,files: {
'dist/<%= pkg.name %>.bundle.min.js': 'dist/<%= pkg.name %>.bundle.js',
}
}
},
shell: {

@@ -78,3 +51,3 @@ "generate-vim-tags-file": {

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

@@ -85,18 +58,6 @@ }

command: function () {
var cmd = 'browserify --debug --standalone=TtyTable '+_ignore+' -r ./src/main.js > ./dist/<%= pkg.name %>.devel.js';
var cmd = 'browserify --debug --standalone=TtyTable '+_ignore+' -r ./src/main.js > ./dist/<%= pkg.name %>.devel.js -t [ babelify --presets [ es2015 babili] ]';
return cmd;
}
},
"browserify-prod-bundle": {
command: function () {
var cmd = 'browserify '+_ignore+' -r ./src/main.js:<%= pkg.name %> > ./dist/<%= pkg.name %>.bundle.js';
return cmd;
}
},
"browserify-devel-bundle": {
command: function () {
var cmd = 'browserify --debug '+_ignore+' -r ./src/main.js:<%= pkg.name %> > ./dist/<%= pkg.name %>.bundle.devel.js';
return cmd;
}
},
"cleanup" : {

@@ -128,3 +89,3 @@ command: function(){

var jobQueue = [];
var Orgy = require('orgy');
var orgy = require('orgy');
var fs = require('fs');

@@ -134,6 +95,6 @@

var list = glob.sync('examples/*.js');
list.forEach(function(element,index,array){
list.forEach(function(element){
//Create a deferred for each run, which is pushed into a queue.
var deferred = Orgy.deferred();
var deferred = orgy.deferred();
jobQueue.push(deferred);

@@ -147,3 +108,3 @@

var subname = element.split('.')[0];
filename = subname + '-output.txt';
var filename = subname + '-output.txt';
fs.writeFileSync(filename,stdout);

@@ -156,3 +117,3 @@ grunt.log.write('Wrote output to text file: ' + filename + '\n');

//Resolve grunt deferred only after jobQueue is complete.
Orgy.queue(jobQueue,[{
orgy.queue(jobQueue,[{
timeout : 1000

@@ -168,12 +129,12 @@ }])

var gruntDeferred = this.async(),
Orgy = require('orgy'),
deferred1 = Orgy.deferred({timeout : 20000}),
deferred2 = Orgy.deferred({timeout : 20000}),
queue = Orgy.queue([deferred1,deferred2],{
timeout : 20000
})
.done(function(){
gruntDeferred();
}),
orgy = require('orgy'),
deferred1 = orgy.deferred({timeout : 20000}),
deferred2 = orgy.deferred({timeout : 20000}),
fs = require('fs');
orgy.queue([deferred1,deferred2],{
timeout : 20000
})
.done(function(){
gruntDeferred();
});

@@ -192,3 +153,3 @@ //Get README

readme = readme.replace(/<!--EXAMPLE-USAGE-->((?:.|[\r\n])*)<!--END-EXAMPLE-USAGE-->/m,
'<!--EXAMPLE-USAGE-->\n'+example1+'\n<!--END-EXAMPLE-USAGE-->');
'<!--EXAMPLE-USAGE-->\n'+example1+'\n<!--END-EXAMPLE-USAGE-->');
deferred1.resolve();

@@ -209,3 +170,2 @@

readme = readme.replace(/<!--API-REF-->((?:.|[\r\n])*)<!--END-API-REF-->/m,

@@ -221,3 +181,2 @@ '<!--API-REF-->\n\n'+str+'\n<!--END-API-REF-->');

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-shell');

@@ -249,5 +208,2 @@ grunt.loadNpmTasks('grunt-mocha-test');

'shell:browserify-devel-standalone',
'shell:browserify-prod-bundle',
'shell:browserify-devel-bundle',
'uglify',
'shell:cleanup',

@@ -254,0 +210,0 @@ 'doc'

{
"name": "tty-table",
"version": "2.2.5",
"version": "2.3.0",
"description": "Command line table generator.",

@@ -35,21 +35,25 @@ "main": "src/main.js",

"chalk": "^1.1.0",
"csv": "^0.4.6",
"csv": "^1.1.1",
"merge": "^1.2.0",
"minimist": "^1.2.0",
"strip-ansi": "^3.0.0",
"wcwidth": "^1.0.1",
"word-wrap": "^1.1.0"
"smartwrap": "^1.0.3",
"strip-ansi": "^3.0.0"
},
"devDependencies": {
"babel-preset-babili": "0.0.12",
"babel-preset-es2015": "^6.24.1",
"babelify": "^7.3.0",
"browserify-banner": "^1.0.4",
"chai": "^3.0.0",
"glob": "^6.0.1",
"grunt": "^0.4.5",
"grunt-contrib-uglify": "^0.9.1",
"grunt-jsdoc": "^0.6.7",
"grunt-mocha": "^0.4.13",
"grunt-mocha-test": "^0.12.7",
"grunt-shell": "^1.1.2",
"mocha": "^2.2.5",
"glob": "^7.1.2",
"grunt": "^1.0.1",
"grunt-contrib-uglify": "^3.0.1",
"grunt-contrib-watch": "^1.0.0",
"grunt-jsdoc": "^2.1.0",
"grunt-mocha": "^1.0.4",
"grunt-mocha-test": "^0.13.2",
"grunt-shell": "^2.1.0",
"mocha": "^3.4.1",
"orgy": "^2.0.6"
}
}

@@ -12,3 +12,3 @@ # tty-table

```
$ sudo apt-get install nodejs //if not already installed
$ sudo apt-get install nodejs
$ npm install tty-table -g

@@ -25,7 +25,7 @@ ```

```
```html
<script src="tty-table.bundle.min.js"></script>
<script>
var Table = require('tty-table');
...
var Table = require('tty-table');
...
</script>

@@ -36,4 +36,4 @@ ```

### Drop-in replacement for [Automattic/cli-table](docs/automattic-cli-table.md):
```
### Drop-in replacement for the unmaintained [Automattic/cli-table](docs/automattic-cli-table.md):
```js
var Table = require('tty-table')('automattic-cli-table');

@@ -62,15 +62,15 @@ //now runs with same syntax as Automattic/cli-table

## Example Output
## Output Examples
### Terminal Application
### Terminal
(npm i -g tty-table)
![Terminal Application Example](https://cloud.githubusercontent.com/assets/7478359/15691533/39f5fed4-273e-11e6-81a6-533bd8dbd1c4.gif "Terminal Application Example")
![Static](https://cloud.githubusercontent.com/assets/7478359/15691679/07142030-273f-11e6-8f1e-25728d558a2d.png "Static Example")
### Nodejs Module
![Terminal Example](https://cloud.githubusercontent.com/assets/7478359/15691679/07142030-273f-11e6-8f1e-25728d558a2d.png "Terminal Example")
![Streaming](https://cloud.githubusercontent.com/assets/7478359/15691533/39f5fed4-273e-11e6-81a6-533bd8dbd1c4.gif "Streaming Example")
### Browser & Browser Console
![Browser Console Example](https://cloud.githubusercontent.com/assets/7478359/15691676/043a47ea-273f-11e6-8889-df03e8a25e26.png "Browser Console Example")
![Browser Console Example](https://cloud.githubusercontent.com/assets/7478359/25214897/df99d2e8-254e-11e7-962f-743890292a24.png)
[Working Example in Browser](https://cdn.rawgit.com/tecfu/tty-table/master/examples/browser-example.html)

@@ -280,2 +280,3 @@

| options.borderColor | <code>string</code> | default: terminal's default color |
| options.compact | <code>boolean</code> | default: false Removes horizontal lines when true. |
| options.defaultErrorValue | <code>mixed</code> | default: 'ERROR!' |

@@ -342,2 +343,2 @@ | options.defaultValue | <code>mixed</code> | default: '?' |

Copyright 2015-2016, Tecfu.
Copyright 2015-2017, Tecfu.

@@ -1,3 +0,4 @@

var StripAnsi = require("strip-ansi");
var Wrap = require("word-wrap");
//var StripAnsi = require("strip-ansi");
//var Wrap = require("word-wrap");
var Wrap = require("smartwrap");
var Wcwidth = require("wcwidth");

@@ -130,6 +131,4 @@ var Format = {};

string = strArr.join('\n');
return {
output : string,
output : strArr,
width : innerWidth

@@ -169,8 +168,10 @@ };

Format.handleLatinChars = function(string,cellOptions,innerWidth){
var calculatedWidth = innerWidth -
cellOptions.paddingLeft -
cellOptions.paddingRight;
var outstring = Wrap(string,{
width : innerWidth -
cellOptions.paddingLeft -
cellOptions.paddingRight,
trim : true,
indent : ''
width : calculatedWidth,
trim : true//,
//indent : '',
//cut : true
});

@@ -177,0 +178,0 @@

@@ -38,2 +38,4 @@ var Merge = require("merge");

* @param {string} options.borderColor - default: terminal's default color
* @param {boolean} options.compact - default: false
* Removes horizontal lines when true.
* @param {mixed} options.defaultErrorValue - default: 'ERROR!'

@@ -40,0 +42,0 @@ * @param {mixed} options.defaultValue - default: '?'

@@ -53,2 +53,3 @@ var Merge = require("merge");

//add borders
//0=header, 1=body, 2=footer
for(var a=0; a<3; a++){

@@ -64,3 +65,4 @@ borders.push('');

borders[a] = borders[a].join('');
borders[a] = marginLeft + borders[a] + '\n';
//no trailing space on footer
borders[a] = (a<2) ? marginLeft + borders[a] + '\n' : marginLeft + borders[a];
}

@@ -124,3 +126,8 @@

return Array(Config.marginTop + 1).join('\n') + output;
var finalOutput = Array(Config.marginTop + 1).join('\n') + output;
//record the height of the output
this.height = finalOutput.split(/\r\n|\r|\n/).length;
return finalOutput;
};

@@ -181,3 +188,2 @@

.map(Function.call,function(){return []});
cArrs.forEach(function(cellArr,a){

@@ -242,14 +248,8 @@ var whiteline = Array(config.table.columnWidths[a]).join('\ ');

//textwrap cellValue
var WrapObj = Format.wrapCellContent(
config,
cellValue,
columnIndex,
cellOptions,
rowType
);
cellValue = WrapObj.output;
var WrapObj = Format.wrapCellContent(config, cellValue, columnIndex, cellOptions, rowType);
//cellValue = WrapObj.output.join('\n');
//return as array of lines
return {
cellArr : cellValue.split('\n'),
cellArr : WrapObj.output,
width : WrapObj.width

@@ -256,0 +256,0 @@ };

@@ -25,2 +25,3 @@ #!/usr/bin/env node

var alreadyRendered = false;
var previousHeight = 0;

@@ -53,9 +54,14 @@ //check format of input data

//hide cursor
console.log('\u001b[?25l');
//wipe existing if already rendered
if(alreadyRendered){
//move cursor up number to the top of the previous print
//before deleting
console.log('\u001b['+(previousHeight+3)+'A');
//delete to end of terminal
console.log('\u001b[0J');
//move cursor up number of spaces equal to table height + 1
console.log('\u001b['+(input.length+7)+'A');
}

@@ -65,3 +71,9 @@ else{

}
console.log(t1.render());
//reset the previous height to the height of this output
//for when we next clear the print
previousHeight = t1.height;
};

@@ -103,4 +115,3 @@

//nothing
});

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 not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc