Comparing version 2.2.5 to 2.3.0
@@ -12,16 +12,15 @@ | ||
┌─────┬────────────────────┬────────────────────────┬────────────────┐ | ||
│[33m Rel [39m│[33m Change [39m│[33m By [39m│[33m When [39m│ | ||
│[33m Re [39m│[33m Change [39m│[33m By [39m│[33m When [39m│ | ||
│[33m l [39m│ │ │ │ | ||
├─────┼────────────────────┼────────────────────────┼────────────────┤ | ||
│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 @@ │[32m Some Key [39m│ Some Value │ | ||
┌───────────────────┬───────────────────┬───────────────────┐ | ||
@@ -51,2 +48,1 @@ │ │[33m Header #1 [39m│[33m Header #2 [39m│ | ||
└───────────────────┴───────────────────┴───────────────────┘ | ||
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 @@ │[36m item [39m│[33m price [39m│[33m Is organic? [39m│ | ||
└─────────────────────────────┴─────────┴──────────────┘ | ||
@@ -28,3 +28,2 @@ | ||
┌───────────────────┬─────────┬─────────┐ | ||
@@ -51,2 +50,1 @@ │[33m item [39m│[33m price [39m│[33m organic [39m│ | ||
└───────────────────┴─────────┴─────────┘ | ||
@@ -8,3 +8,2 @@ | ||
┌─────────┬─────────┬─────────┐ | ||
@@ -16,3 +15,2 @@ │[33m item [39m│[33m price [39m│[33m organic [39m│ | ||
┌─────────┬─────────┬─────────┐ | ||
@@ -23,2 +21,1 @@ │[33m item [39m│[33m price [39m│[33m or... [39m│ | ||
└─────────┴─────────┴─────────┘ | ||
@@ -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
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
6
19916
0
339
24
1508276
15
+ Addedsmartwrap@^1.0.3
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedbreakword@1.0.6(transitive)
+ Addedcamelcase@5.3.1(transitive)
+ Addedcliui@6.0.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcsv@1.2.1(transitive)
+ Addedcsv-generate@1.1.2(transitive)
+ Addedcsv-stringify@1.1.2(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedfind-up@4.1.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedgrapheme-splitter@1.0.4(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedlocate-path@5.0.0(transitive)
+ Addedlodash.get@4.4.2(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@4.1.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedrequire-main-filename@2.0.0(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedsmartwrap@1.2.5(transitive)
+ Addedstream-transform@0.2.2(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedwhich-module@2.0.1(transitive)
+ Addedwrap-ansi@6.2.0(transitive)
+ Addedy18n@4.0.3(transitive)
+ Addedyargs@15.4.1(transitive)
+ Addedyargs-parser@18.1.3(transitive)
- Removedwcwidth@^1.0.1
- Removedword-wrap@^1.1.0
- Removedcsv@0.4.6(transitive)
- Removedcsv-generate@0.0.6(transitive)
- Removedcsv-stringify@0.0.8(transitive)
- Removedstream-transform@0.1.2(transitive)
- Removedword-wrap@1.2.5(transitive)
Updatedcsv@^1.1.1