Comparing version 0.0.3 to 0.0.4
@@ -5,8 +5,17 @@ #!/usr/bin/env node | ||
var table = asciitable([ | ||
{ab: "a", b: "b", c: "c"}, | ||
{ab: "asddsfa", b: "sss", c: "zxc"}, | ||
{ab: "dsgvdgsdvgssdf", b: "x", c: "eryty"}, | ||
{ab: "m", b: "n", c: "o", de: "p"}, | ||
{ab: 5, b: null, c: {}, de: []}, | ||
var options = { | ||
columns: [ | ||
{field: "ab", name: "First"}, | ||
{field: "b", name: "Second"}, | ||
{field: "c", name: "Third"}, | ||
{field: "de", name: "Fourth"}, | ||
], | ||
}; | ||
var table = asciitable(options, [ | ||
{ab: "a", b: "b", c: "c" }, | ||
{ab: "asddsfa", b: "sss", c: "zxc" }, | ||
{ab: "dsgvdgsdvgssdf", b: "x", c: "eryty" }, | ||
{ab: "m", b: "n", c: "o", de: "p"}, | ||
{ab: 5, b: null, c: {}, de: [] }, | ||
{ab: function(){}}, | ||
@@ -13,0 +22,0 @@ ]); |
16
index.js
@@ -28,6 +28,12 @@ var asciitable = module.exports = function asciitable(options, data) { | ||
columns = columns.map(function(e) { | ||
return { | ||
field: e, | ||
width: e.length, | ||
}; | ||
if (typeof e === "string") { | ||
e = { | ||
name: e, | ||
field: e, | ||
}; | ||
} | ||
e.width = e.name.length; | ||
return e; | ||
}); | ||
@@ -50,3 +56,3 @@ | ||
output.push(separator); | ||
output.push([""].concat(columns.map(function(e) { return pad(e.field, e.width); })).concat([""]).join(" | ")); | ||
output.push([""].concat(columns.map(function(e) { return pad(e.name, e.width); })).concat([""]).join(" | ")); | ||
output.push(separator); | ||
@@ -53,0 +59,0 @@ data.forEach(function(row) { |
{ | ||
"name": "asciitable", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Render tables in text for tabular terminal fun times!", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -77,9 +77,18 @@ asciitable | ||
var table = asciitable([ | ||
{a: "a", b: "b", c: "c"}, | ||
{a: "asddsfa", b: "sss", c: "zxc"}, | ||
{a: "dsgvdgsdvgssdf", b: "x", c: "eryty"}, | ||
{a: "m", b: "n", c: "o", d: "p"}, | ||
{a: 5, b: null, c: {}, d: []}, | ||
{a: function(){}}, | ||
var options = { | ||
columns: [ | ||
{field: "ab", name: "First"}, | ||
{field: "b", name: "Second"}, | ||
{field: "c", name: "Third"}, | ||
{field: "de", name: "Fourth"}, | ||
], | ||
}; | ||
var table = asciitable(options, [ | ||
{ab: "a", b: "b", c: "c" }, | ||
{ab: "asddsfa", b: "sss", c: "zxc" }, | ||
{ab: "dsgvdgsdvgssdf", b: "x", c: "eryty" }, | ||
{ab: "m", b: "n", c: "o", de: "p"}, | ||
{ab: 5, b: null, c: {}, de: [] }, | ||
{ab: function(){}}, | ||
]); | ||
@@ -93,12 +102,12 @@ | ||
``` | ||
------------------------------------------------- | ||
| a | b | c | d | | ||
------------------------------------------------- | ||
| a | b | c | | | ||
| asddsfa | sss | zxc | | | ||
| dsgvdgsdvgssdf | x | eryty | | | ||
| m | n | o | p | | ||
| 5 | null | [object Object] | | | ||
| function (){} | | | | | ||
------------------------------------------------- | ||
-------------------------------------------------------- | ||
| First | Second | Third | Fourth | | ||
-------------------------------------------------------- | ||
| a | b | c | | | ||
| asddsfa | sss | zxc | | | ||
| dsgvdgsdvgssdf | x | eryty | | | ||
| m | n | o | p | | ||
| 5 | null | [object Object] | | | ||
| function (){} | | | | | ||
-------------------------------------------------------- | ||
``` | ||
@@ -105,0 +114,0 @@ |
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
7233
70
125