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

table

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

table - npm Package Compare versions

Comparing version 6.0.2 to 6.0.3

10

dist/alignString.js

@@ -8,2 +8,6 @@ "use strict";

var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
var _isString2 = _interopRequireDefault(require("lodash/isString"));
var _stringWidth = _interopRequireDefault(require("string-width"));

@@ -63,7 +67,7 @@

const alignString = (subject, containerWidth, alignment) => {
if (typeof subject !== 'string') {
if (!(0, _isString2.default)(subject)) {
throw new TypeError('Subject parameter value must be a string.');
}
if (typeof containerWidth !== 'number') {
if (!(0, _isNumber2.default)(containerWidth)) {
throw new TypeError('Container width parameter value must be a number.');

@@ -79,3 +83,3 @@ }

if (typeof alignment !== 'string') {
if (!(0, _isString2.default)(alignment)) {
throw new TypeError('Alignment parameter value must be a string.');

@@ -82,0 +86,0 @@ }

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

var _isString2 = _interopRequireDefault(require("lodash/isString"));
var _wrapCell = _interopRequireDefault(require("./wrapCell"));

@@ -20,3 +22,3 @@

const calculateCellHeight = (value, columnWidth, useWrapWord = false) => {
if (typeof value !== 'string') {
if (!(0, _isString2.default)(value)) {
throw new TypeError('Value must be a string.');

@@ -23,0 +25,0 @@ }

@@ -8,2 +8,8 @@ "use strict";

var _max2 = _interopRequireDefault(require("lodash/max"));
var _isBoolean2 = _interopRequireDefault(require("lodash/isBoolean"));
var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
var _calculateCellHeight = _interopRequireDefault(require("./calculateCellHeight"));

@@ -26,7 +32,7 @@

cells.forEach((value, index1) => {
if (typeof config.columns[index1].width !== 'number') {
if (!(0, _isNumber2.default)(config.columns[index1].width)) {
throw new TypeError('column[index].width must be a number.');
}
if (typeof config.columns[index1].wrapWord !== 'boolean') {
if (!(0, _isBoolean2.default)(config.columns[index1].wrapWord)) {
throw new TypeError('column[index].wrapWord must be a boolean.');

@@ -37,3 +43,3 @@ }

});
rowSpanIndex.push(Math.max(...cellHeightIndex));
rowSpanIndex.push((0, _max2.default)(cellHeightIndex));
});

@@ -40,0 +46,0 @@ return rowSpanIndex;

@@ -8,2 +8,8 @@ "use strict";

var _mapValues2 = _interopRequireDefault(require("lodash/mapValues"));
var _values2 = _interopRequireDefault(require("lodash/values"));
var _trimEnd2 = _interopRequireDefault(require("lodash/trimEnd"));
var _alignTableData = _interopRequireDefault(require("./alignTableData"));

@@ -62,3 +68,3 @@

output += (0, _drawBorder.drawBorderBottom)(columnWidthIndex, config.border);
output = output.trimEnd();
output = (0, _trimEnd2.default)(output);
process.stdout.write(output);

@@ -89,3 +95,3 @@ };

output += bottom;
output = output.trimEnd();
output = (0, _trimEnd2.default)(output);
process.stdout.write(output);

@@ -100,6 +106,7 @@ };

const createStream = (userConfig = {}) => {
const config = (0, _makeStreamConfig.default)(userConfig);
const columnWidthIndex = Object.values(config.columns).map(column => {
const config = (0, _makeStreamConfig.default)(userConfig); // @todo Use 'Object.values' when Node.js v6 support is dropped.
const columnWidthIndex = (0, _values2.default)((0, _mapValues2.default)(config.columns, column => {
return column.width + column.paddingLeft + column.paddingRight;
});
}));
let empty;

@@ -106,0 +113,0 @@ empty = true;

@@ -8,2 +8,8 @@ "use strict";

var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
var _times2 = _interopRequireDefault(require("lodash/times"));
var _calculateMaximumColumnWidthIndex = _interopRequireDefault(require("./calculateMaximumColumnWidthIndex"));

@@ -17,8 +23,2 @@

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/**

@@ -46,5 +46,4 @@ * Merges user provided border characters with the default border ("honeywell") characters.

const maximumColumnWidthIndex = (0, _calculateMaximumColumnWidthIndex.default)(rows);
for (let index = rows[0].length; index--;) {
if (!columns[index]) {
(0, _times2.default)(rows[0].length, index => {
if ((0, _isUndefined2.default)(columns[index])) {
columns[index] = {};

@@ -61,4 +60,3 @@ }

}, columnDefault, columns[index]);
}
});
return columns;

@@ -78,5 +76,3 @@ };

(0, _validateConfig.default)('config.json', userConfig);
const config = _objectSpread({}, userConfig);
const config = (0, _cloneDeep2.default)(userConfig);
config.border = makeBorder(config.border);

@@ -83,0 +79,0 @@ config.columns = makeColumns(rows, config.columns, config.columnDefault);

@@ -8,2 +8,8 @@ "use strict";

var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
var _times2 = _interopRequireDefault(require("lodash/times"));
var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters"));

@@ -15,8 +21,2 @@

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/**

@@ -43,6 +43,4 @@ * Merges user provided border characters with the default border ("honeywell") characters.

const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
let index = columnCount;
while (index--) {
if (!columns[index]) {
(0, _times2.default)(columnCount, index => {
if ((0, _isUndefined2.default)(columns[index])) {
columns[index] = {};

@@ -58,4 +56,3 @@ }

}, columnDefault, columns[index]);
}
});
return columns;

@@ -91,5 +88,4 @@ };

(0, _validateConfig.default)('streamConfig.json', userConfig);
const config = (0, _cloneDeep2.default)(userConfig);
const config = _objectSpread({}, userConfig);
if (!config.columnDefault || !config.columnDefault.width) {

@@ -96,0 +92,0 @@ throw new Error('Must provide config.columnDefault.width when creating a stream.');

@@ -8,2 +8,6 @@ "use strict";

var _flatten2 = _interopRequireDefault(require("lodash/flatten"));
var _times2 = _interopRequireDefault(require("lodash/times"));
var _wrapCell = _interopRequireDefault(require("./wrapCell"));

@@ -22,5 +26,3 @@

const mappedRows = unmappedRows.map((cells, index0) => {
const rowHeight = Array.from({
length: rowHeightIndex[index0]
}, () => {
const rowHeight = (0, _times2.default)(rowHeightIndex[index0], () => {
return new Array(tableWidth).fill('');

@@ -38,5 +40,4 @@ }); // rowHeight

return rowHeight;
}); // flat array
return [].concat(...mappedRows);
});
return (0, _flatten2.default)(mappedRows);
};

@@ -43,0 +44,0 @@

@@ -8,5 +8,6 @@ "use strict";

const truncate = (string, length) => {
return string.length > length ? string.slice(0, Math.max(0, length - 3)) + '...' : string;
};
var _truncate2 = _interopRequireDefault(require("lodash/truncate"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -18,8 +19,8 @@ * @todo Make it work with ASCII content.

*/
const truncateTableData = (rows, config) => {
return rows.map(cells => {
return cells.map((content, index) => {
return truncate(content, config.columns[index].truncate);
return (0, _truncate2.default)(content, {
length: config.columns[index].truncate
});
});

@@ -26,0 +27,0 @@ });

@@ -9,2 +9,3 @@ {

"ajv": "^6.12.4",
"lodash": "^4.17.20",
"slice-ansi": "^4.0.0",

@@ -24,2 +25,3 @@ "string-width": "^4.2.0"

"babel-plugin-istanbul": "^6.0.0",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-transform-export-default-name": "^2.0.4",

@@ -83,3 +85,3 @@ "chai": "^4.2.0",

},
"version": "6.0.2"
"version": "6.0.3"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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