Comparing version 0.0.1 to 0.0.2
19
index.js
@@ -7,4 +7,9 @@ var asciitable = module.exports = function asciitable(options, data) { | ||
if (typeof options === "object" && Array.isArray(options) && typeof data === "undefined") { | ||
if (typeof options === "object" && Array.isArray(options)) { | ||
var tmp = data; | ||
data = options; | ||
options = tmp; | ||
} | ||
if (!options) { | ||
options = {}; | ||
@@ -40,17 +45,15 @@ } | ||
var total_width = columns.reduce(function(i, v) { | ||
return i + v.width + 3; | ||
}, 4); | ||
var output = []; | ||
output.push((new Array(total_width)).join("-")); | ||
var separator = [""].concat(columns.map(function(e) { return (new Array(e.width + 1)).join("-"); })).concat([""]).join(options.plusIntersections ? "-+-" : "---"); | ||
output.push(separator); | ||
output.push([""].concat(columns.map(function(e) { return pad(e.field, e.width); })).concat([""]).join(" | ")); | ||
output.push((new Array(total_width)).join("-")); | ||
output.push(separator); | ||
data.forEach(function(row) { | ||
output.push([""].concat(columns.map(function(column) { return pad(row[column.field], column.width); })).concat([""]).join(" | ")); | ||
}); | ||
output.push((new Array(total_width)).join("-")); | ||
output.push(separator); | ||
return output.join("\n"); | ||
}; |
{ | ||
"name": "asciitable", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Render tables in text for tabular terminal fun times!", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -32,3 +32,11 @@ asciitable | ||
```javascript | ||
var table = asciitable([options], data); | ||
var table = asciitable(options, data); | ||
// OR | ||
var table = asciitable(data, options); | ||
// OR | ||
var table = asciitable(data); | ||
``` | ||
@@ -59,2 +67,4 @@ | ||
array. | ||
* _plusIntersections_ - enables using a `+` character at line intersections. | ||
Default is false. Or undefined. Whatever, default is "not enabled". | ||
@@ -61,0 +71,0 @@ Example |
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
6494
58
116