Comparing version
15
index.js
@@ -20,2 +20,3 @@ "use strict" | ||
paddingChr: ' ', | ||
showHeaders: true, | ||
headingTransform: function(key) { | ||
@@ -46,2 +47,3 @@ return key.toUpperCase() | ||
options.preserveNewLines = !!options.preserveNewLines | ||
options.showHeaders = !!options.showHeaders; | ||
options.columns = options.columns || options.include // alias include/columns, prefer columns if supplied | ||
@@ -106,8 +108,9 @@ var columnNames = options.columns || [] // optional user-supplied columns to include | ||
var headers = {} | ||
columnNames.forEach(function(columnName) { | ||
var column = columns[columnName] | ||
headers[columnName] = column.headingTransform(columnName) | ||
}) | ||
items.unshift(headers) | ||
if(options.showHeaders) { | ||
columnNames.forEach(function(columnName) { | ||
var column = columns[columnName] | ||
headers[columnName] = column.headingTransform(columnName) | ||
}) | ||
items.unshift(headers) | ||
} | ||
// get actual max-width between min & max | ||
@@ -114,0 +117,0 @@ // based on length of data in columns |
{ | ||
"name": "columnify", | ||
"version": "1.2.0-alpha", | ||
"version": "1.2.0", | ||
"description": "Render data in text columns, supports in-column text-wrap.", | ||
@@ -35,3 +35,3 @@ "main": "index.js", | ||
"strip-ansi": "^1.0.0", | ||
"wcwidth.js": "~0.0.4" | ||
"wcwidth": "^1.0.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "directories": { |
@@ -194,3 +194,3 @@ # columnify | ||
### Align Right | ||
### Align Right/Center | ||
@@ -215,2 +215,23 @@ ```js | ||
Align Center works in a similar way. | ||
### Padding | ||
```js | ||
var data = { | ||
"shortKey": "veryVeryVeryVeryVeryLongVal", | ||
"veryVeryVeryVeryVeryLongKey": "shortVal" | ||
} | ||
columnify(data, { paddingChr: '.'}) | ||
``` | ||
#### Output: | ||
``` | ||
KEY........................ VALUE...................... | ||
shortKey................... veryVeryVeryVeryVeryLongVal | ||
veryVeryVeryVeryVeryLongKey shortVal................... | ||
``` | ||
### Preserve existing newlines | ||
@@ -349,3 +370,1 @@ | ||
MIT | ||
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
22800
2.24%378
1.07%0
-100%368
5.44%1
Infinity%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed