Socket
Socket
Sign inDemoInstall

columnify

Package Overview
Dependencies
2
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

width.js

6

index.js
"use strict"
var wcwidth = require('wcwidth.js')({ monkeypatch: false, control: 0 })
var wcwidth = require('./width')
var utils = require('./utils')
var padRight = utils.padRight
var padLeft = utils.padLeft
var splitIntoLines = utils.splitIntoLines

@@ -191,3 +192,4 @@ var splitLongWords = utils.splitLongWords

var val = item[columnName][i] || '' // || '' ensures empty columns get padded
row[i].push(padRight(val, column.width))
if (column.align == 'right') row[i].push(padLeft(val, column.width))
else row[i].push(padRight(val, column.width))
})

@@ -194,0 +196,0 @@ }

{
"name": "columnify",
"version": "1.0.0",
"version": "1.1.0",
"description": "Render data in text columns, supports in-column text-wrap.",

@@ -12,2 +12,3 @@ "main": "index.js",

"devDependencies": {
"chalk": "^0.4.0",
"faucet": "0.0.1",

@@ -34,2 +35,3 @@ "tape": "~2.12.3"

"dependencies": {
"strip-ansi": "^0.2.1",
"wcwidth.js": "~0.0.4"

@@ -36,0 +38,0 @@ },

@@ -194,2 +194,22 @@ # columnify

### Align Right
```js
var data = {
"mocha@1.18.2": 1,
"commander@2.0.0": 1,
"debug@0.8.1": 1
}
columnify(data, {config: {value: {align: 'right'}}})
```
#### Output:
```
KEY VALUE
mocha@1.18.2 1
commander@2.0.0 1
debug@0.8.1 1
```
### Preserve existing newlines

@@ -196,0 +216,0 @@

"use strict"
var wcwidth = require('wcwidth.js')({ monkeypatch: false, control: 0 })
var wcwidth = require('./width')

@@ -25,2 +25,20 @@ /**

/**
* Pad `str` up to total length `max` with `chr`, on the left.
* If `str` is longer than `max`, padRight will return `str` unaltered.
*
* @param String str string to pad
* @param Number max total length of output string
* @param String chr optional. Character to pad with. default: ' '
* @return String padded str
*/
function padLeft(str, max, chr) {
str = str != null ? str : ''
str = String(str)
var length = 1 + max - wcwidth(str)
if (length <= 0) return str
return Array.apply(null, {length: length}).join(chr || ' ') + str
}
/**
* Split a String `str` into lines of maxiumum length `max`.

@@ -129,2 +147,3 @@ * Splits on word boundaries. Preserves existing new lines.

module.exports.padRight = padRight
module.exports.padLeft = padLeft
module.exports.splitIntoLines = splitIntoLines

@@ -131,0 +150,0 @@ module.exports.splitLongWords = splitLongWords

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc