Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

columnify

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

columnify - npm Package Compare versions

Comparing version 1.5.3 to 1.5.4

LICENSE

4

columnify.js

@@ -148,2 +148,4 @@ "use strict";

}).reduce(function (min, cur) {
// if already at maxWidth don't bother testing
if (min >= column.maxWidth) return min;
return Math.max(min, Math.min(column.maxWidth, Math.max(column.minWidth, wcwidth(cur))));

@@ -185,5 +187,7 @@ }, 0);

return item[columnName].reduce(function (min, cur) {
if (min >= column.maxWidth) return min;
return Math.max(min, Math.min(column.maxWidth, Math.max(column.minWidth, wcwidth(cur))));
}, 0);
}).reduce(function (min, cur) {
if (min >= column.maxWidth) return min;
return Math.max(min, Math.min(column.maxWidth, Math.max(column.minWidth, cur)));

@@ -190,0 +194,0 @@ }, 0);

@@ -138,2 +138,4 @@ "use strict"

.reduce((min, cur) => {
// if already at maxWidth don't bother testing
if (min >= column.maxWidth) return min
return Math.max(min, Math.min(column.maxWidth, Math.max(column.minWidth, wcwidth(cur))))

@@ -175,5 +177,7 @@ }, 0)

return item[columnName].reduce((min, cur) => {
if (min >= column.maxWidth) return min
return Math.max(min, Math.min(column.maxWidth, Math.max(column.minWidth, wcwidth(cur))))
}, 0)
}).reduce((min, cur) => {
if (min >= column.maxWidth) return min
return Math.max(min, Math.min(column.maxWidth, Math.max(column.minWidth, cur)))

@@ -180,0 +184,0 @@ }, 0)

2

package.json
{
"name": "columnify",
"version": "1.5.3",
"version": "1.5.4",
"description": "Render data in text columns. Supports in-column text-wrap.",

@@ -5,0 +5,0 @@ "main": "columnify.js",

@@ -111,29 +111,42 @@ "use strict"

function splitLongWords(str, max, truncationChar, result) {
function splitLongWords(str, max, truncationChar) {
str = str.trim()
result = result || []
if (!str) return result.join(' ') || ''
var result = []
var words = str.split(' ')
var word = words.shift() || str
if (wcwidth(word) > max) {
// slice is based on length no wcwidth
var i = 0
var wwidth = 0
var limit = max - wcwidth(truncationChar)
while (i < word.length) {
var w = wcwidth(word.charAt(i))
if(w + wwidth > limit)
break
wwidth += w
++i
var remainder = ''
var truncationWidth = wcwidth(truncationChar)
while (remainder || words.length) {
if (remainder) {
var word = remainder
remainder = ''
} else {
var word = words.shift()
}
var remainder = word.slice(i) // get remainder
words.unshift(remainder) // save remainder for next loop
if (wcwidth(word) > max) {
// slice is based on length no wcwidth
var i = 0
var wwidth = 0
var limit = max - truncationWidth
while (i < word.length) {
var w = wcwidth(word.charAt(i))
if (w + wwidth > limit) {
break
}
wwidth += w
++i
}
word = word.slice(0, i) // grab truncated word
word += truncationChar // add trailing … or whatever
remainder = word.slice(i) // get remainder
// save remainder for next loop
word = word.slice(0, i) // grab truncated word
word += truncationChar // add trailing … or whatever
}
result.push(word)
}
result.push(word)
return splitLongWords(words.join(' '), max, truncationChar, result)
return result.join(' ')
}

@@ -140,0 +153,0 @@

var stripAnsi = require('strip-ansi')
var wcwidth = require('wcwidth')
var stepSize = 10000
module.exports = function(str) {
// step through data in increments as the stripAnsi
// regex is sensitive to large strings.
var width = 0
for (var i = 0; i < str.length; i += stepSize + 1) {
width += wcwidth(stripAnsi(
str.slice(i, i + stepSize)
))
}
return width
return wcwidth(stripAnsi(str))
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc