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.0 to 1.5.1

67

columnify.js

@@ -1,7 +0,9 @@

"use strict";
'use strict';
var wcwidth = require("./width");
var _toConsumableArray = function (arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } };
var _require = require("./utils");
var wcwidth = require('./width');
var _require = require('./utils');
var padRight = _require.padRight;

@@ -14,7 +16,7 @@ var padCenter = _require.padCenter;

var DEFAULT_HEADING_TRANSFORM = function (key) {
var DEFAULT_HEADING_TRANSFORM = function DEFAULT_HEADING_TRANSFORM(key) {
return key.toUpperCase();
};
var DEFAULT_DATA_TRANSFORM = function (cell, column, index) {
var DEFAULT_DATA_TRANSFORM = function DEFAULT_DATA_TRANSFORM(cell, column, index) {
return cell;

@@ -26,7 +28,7 @@ };

minWidth: 0,
columnSplitter: " ",
columnSplitter: ' ',
truncate: false,
truncateMarker: "…",
truncateMarker: '…',
preserveNewLines: false,
paddingChr: " ",
paddingChr: ' ',
showHeaders: true,

@@ -44,3 +46,3 @@ headingTransform: DEFAULT_HEADING_TRANSFORM,

var maxLineWidth = options.maxLineWidth || Infinity;
if (maxLineWidth === "auto") maxLineWidth = process.stdout.columns || Infinity;
if (maxLineWidth === 'auto') maxLineWidth = process.stdout.columns || Infinity;
delete options.maxLineWidth; // this is a line control option, don't pass it to column

@@ -54,3 +56,3 @@

options.spacing = options.spacing || "\n"; // probably useless
options.spacing = options.spacing || '\n'; // probably useless
options.preserveNewLines = !!options.preserveNewLines;

@@ -86,3 +88,3 @@ options.showHeaders = !!options.showHeaders;

column.truncate = !!column.truncate;
column.align = column.align || "left";
column.align = column.align || 'left';
});

@@ -95,11 +97,11 @@

// null/undefined -> ''
result[columnName] = item[columnName] != null ? item[columnName] : "";
result[columnName] = item[columnName] != null ? item[columnName] : '';
// toString everything
result[columnName] = "" + result[columnName];
result[columnName] = '' + result[columnName];
if (columns[columnName].preserveNewLines) {
// merge non-newline whitespace chars
result[columnName] = result[columnName].replace(/[^\S\n]/gmi, " ");
result[columnName] = result[columnName].replace(/[^\S\n]/gmi, ' ');
} else {
// merge all whitespace chars
result[columnName] = result[columnName].replace(/\s/gmi, " ");
result[columnName] = result[columnName].replace(/\s/gmi, ' ');
}

@@ -119,3 +121,3 @@ });

// disable default heading transform if we wrote to column.name
if (changedKeys.indexOf("name") !== -1) {
if (changedKeys.indexOf('name') !== -1) {
if (column.headingTransform !== DEFAULT_HEADING_TRANSFORM) return;

@@ -140,3 +142,3 @@ column.headingTransform = function (heading) {

if (!column.showHeaders) {
headers[columnName] = "";
headers[columnName] = '';
return;

@@ -226,12 +228,15 @@ }

});
var _loop = function (i) {
row[i] = row[i] || [];
columnNames.forEach(function (columnName) {
var column = columns[columnName];
var val = item[columnName][i] || ''; // || '' ensures empty columns get padded
if (column.align === 'right') row[i].push(padLeft(val, column.width, paddingChr));else if (column.align === 'center' || column.align === 'centre') row[i].push(padCenter(val, column.width, paddingChr));else row[i].push(padRight(val, column.width, paddingChr));
});
};
// combine matching lines of each rows
for (var i = 0; i < numLines; i++) {
(function (i) {
row[i] = row[i] || [];
columnNames.forEach(function (columnName) {
var column = columns[columnName];
var val = item[columnName][i] || ""; // || '' ensures empty columns get padded
if (column.align === "right") row[i].push(padLeft(val, column.width, paddingChr));else if (column.align === "center" || column.align === "centre") row[i].push(padCenter(val, column.width, paddingChr));else row[i].push(padRight(val, column.width, paddingChr));
});
})(i);
_loop(i);
}

@@ -254,9 +259,9 @@ return row;

if (Object.assign) {
return Object.assign.apply(Object, args);
}return ObjectAssign.apply(undefined, args);
return Object.assign.apply(Object, _toConsumableArray(args));
}return ObjectAssign.apply(undefined, _toConsumableArray(args));
}
function ObjectAssign(target, firstSource) {
"use strict";
if (target === undefined || target === null) throw new TypeError("Cannot convert first argument to object");
'use strict';
if (target === undefined || target === null) throw new TypeError('Cannot convert first argument to object');

@@ -308,4 +313,4 @@ var to = Object(target);

var item = {};
item[columnNames[0] || "key"] = key;
item[columnNames[1] || "value"] = items[key];
item[columnNames[0] || 'key'] = key;
item[columnNames[1] || 'value'] = items[key];
rows.push(item);

@@ -312,0 +317,0 @@ }

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

@@ -15,6 +15,6 @@ "main": "columnify.js",

"devDependencies": {
"babel": "^4.6.6",
"babel": "^5.0.10",
"chalk": "^1.0.0",
"tap-spec": "^2.2.2",
"tape": "^3.5.0"
"tap-spec": "^3.0.0",
"tape": "^4.0.0"
},

@@ -21,0 +21,0 @@ "repository": {

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