Socket
Socket
Sign inDemoInstall

tty-table

Package Overview
Dependencies
8
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.3

dist/tty-table.bundle.devel.js

109

Gruntfile.js
/**
* To debug gruntfile:
* node-debug $(which grunt) task
*/
*/
module.exports = function(grunt) {
global.grunt = grunt;
//Modules for browserify to ignore
var _ignore = '--ignore=path --ignore=request --ignore=http --ignore=fs --ignore=vm --ignore=process --ignore=lodash';
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
options : {
timestamp : (function(){
//A FORMATTED TIMESTAMP STRING FOR BACKUP NAMING
var d = new Date(),dstr = '';
dstr = ('0' + d.getHours()).slice(-2)
+ ':' + ('0' + d.getMinutes()).slice(-2)
+ ':' + ('0' + d.getSeconds()).slice(-2);
return dstr;
}())
},
mochaTest: {

@@ -22,2 +38,61 @@ test: {

}
},
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: {
"browserify-prod-standalone": {
command: function () {
var cmd = 'browserify --debug --standalone=TtyTable '+_ignore+' -r ./src/main.js > ./dist/<%= pkg.name %>.js';
return cmd;
}
},
"browserify-devel-standalone": {
command: function () {
var cmd = 'browserify --debug --standalone=TtyTable '+_ignore+' -r ./src/main.js > ./dist/<%= pkg.name %>.devel.js';
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" : {
command: function(){
return "rm ./dist/<%= pkg.name %>.js ./dist/<%= pkg.name %>.bundle.js";
}
}
}

@@ -29,7 +104,10 @@ });

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

@@ -47,3 +125,3 @@

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

@@ -68,3 +146,3 @@ '<!--EXAMPLE-USAGE-->\n'+example1+'\n<!--END-EXAMPLE-USAGE-->');

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

@@ -77,2 +155,5 @@ fs.writeFileSync("./README.md",readme);

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-mocha-test');

@@ -83,3 +164,3 @@

]);
grunt.registerTask('t', [

@@ -94,4 +175,10 @@ 'mochaTest:test'

grunt.registerTask('default', [
'shell:browserify-prod-standalone',
'shell:browserify-devel-standalone',
'shell:browserify-prod-bundle',
'shell:browserify-devel-bundle',
'uglify',
'shell:cleanup',
'doc'
]);
};

4

package.json
{
"name": "tty-table",
"version": "1.0.0",
"version": "1.0.3",
"description": "Command line table generator.",

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

"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",

@@ -40,0 +42,0 @@ "orgy": "^2.0.6"

# tty-table
A table widget for CLI applications in nodejs.
A terminal table widget for nodejs and the browser.
## Installation
- Nodejs
```

@@ -11,2 +13,12 @@ npm install tty-table

- Browser (via browserify)
```
<script src="tty-table.bundle.min.js"></script>
<script>
var Table = require('tty-table');
...
</script>
```
## Why

@@ -17,10 +29,27 @@

- Optional callbacks on column values
- Header, body column alignment
- Padding
- Works in the browser as well as nodejs
## Example Output
![Example](examples/images/example-1.png "Example")
### Terminal
![Terminal Example](examples/images/example-1.png "Terminal Example")
### Browser & Browser Console
![Browser Console Example](examples/images/example-2.png "Browser Console Example")
[Working example](http://htmlpreview.github.io/?https://raw.githubusercontent.com/tecfu/tty-table/master/examples/example-2.html)
> Note that neither ASCI colors nor default borders are rendered in the browser.
> An alternative border style, as shown below, can be used by setting the option:
>
> ```
> borderStyle : 2
> ```
## Example Usage
<!--EXAMPLE-USAGE-->
```

@@ -90,2 +119,3 @@ var Table = require('tty-table');

<!--API-REF-->
<a name="Table"></a>

@@ -92,0 +122,0 @@ ## Table

@@ -44,2 +44,7 @@ var merge = require("merge"),

{v: "│", l: "└", j: "┴", h: "─", r: "┘"}
],
[
{v: "|", l: "+", j: "+", h: "-", r: "+"},
{v: "|", l: "+", j: "+", h: "-", r: "+"},
{v: "|", l: "+", j: "+", h: "-", r: "+"}
]

@@ -254,3 +259,4 @@ ]

if(totalWidth > process.stdout.columns){
//Check process exists in case we are in browser
if(process && process.stdout && totalWidth > process.stdout.columns){
//recalculate proportionately to fit size

@@ -257,0 +263,0 @@ var prop = process.stdout.columns > totalWidth;

@@ -5,3 +5,2 @@ var chai = require("chai");

var should = chai.should();
var heredoc = require('heredoc');
var fs = require('fs');

@@ -8,0 +7,0 @@

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