Comparing version 6.0.1 to 6.0.2
@@ -8,6 +8,2 @@ "use strict"; | ||
var _isNumber2 = _interopRequireDefault(require("lodash/isNumber")); | ||
var _isString2 = _interopRequireDefault(require("lodash/isString")); | ||
var _stringWidth = _interopRequireDefault(require("string-width")); | ||
@@ -67,7 +63,7 @@ | ||
const alignString = (subject, containerWidth, alignment) => { | ||
if (!(0, _isString2.default)(subject)) { | ||
if (typeof subject !== 'string') { | ||
throw new TypeError('Subject parameter value must be a string.'); | ||
} | ||
if (!(0, _isNumber2.default)(containerWidth)) { | ||
if (typeof containerWidth !== 'number') { | ||
throw new TypeError('Container width parameter value must be a number.'); | ||
@@ -83,3 +79,3 @@ } | ||
if (!(0, _isString2.default)(alignment)) { | ||
if (typeof alignment !== 'string') { | ||
throw new TypeError('Alignment parameter value must be a string.'); | ||
@@ -86,0 +82,0 @@ } |
@@ -8,4 +8,2 @@ "use strict"; | ||
var _isString2 = _interopRequireDefault(require("lodash/isString")); | ||
var _wrapCell = _interopRequireDefault(require("./wrapCell")); | ||
@@ -22,3 +20,3 @@ | ||
const calculateCellHeight = (value, columnWidth, useWrapWord = false) => { | ||
if (!(0, _isString2.default)(value)) { | ||
if (typeof value !== 'string') { | ||
throw new TypeError('Value must be a string.'); | ||
@@ -25,0 +23,0 @@ } |
@@ -8,8 +8,2 @@ "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")); | ||
@@ -32,7 +26,7 @@ | ||
cells.forEach((value, index1) => { | ||
if (!(0, _isNumber2.default)(config.columns[index1].width)) { | ||
if (typeof config.columns[index1].width !== 'number') { | ||
throw new TypeError('column[index].width must be a number.'); | ||
} | ||
if (!(0, _isBoolean2.default)(config.columns[index1].wrapWord)) { | ||
if (typeof config.columns[index1].wrapWord !== 'boolean') { | ||
throw new TypeError('column[index].wrapWord must be a boolean.'); | ||
@@ -43,3 +37,3 @@ } | ||
}); | ||
rowSpanIndex.push((0, _max2.default)(cellHeightIndex)); | ||
rowSpanIndex.push(Math.max(...cellHeightIndex)); | ||
}); | ||
@@ -46,0 +40,0 @@ return rowSpanIndex; |
@@ -8,8 +8,2 @@ "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")); | ||
@@ -68,3 +62,3 @@ | ||
output += (0, _drawBorder.drawBorderBottom)(columnWidthIndex, config.border); | ||
output = (0, _trimEnd2.default)(output); | ||
output = output.trimEnd(); | ||
process.stdout.write(output); | ||
@@ -95,3 +89,3 @@ }; | ||
output += bottom; | ||
output = (0, _trimEnd2.default)(output); | ||
output = output.trimEnd(); | ||
process.stdout.write(output); | ||
@@ -106,7 +100,6 @@ }; | ||
const createStream = (userConfig = {}) => { | ||
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 => { | ||
const config = (0, _makeStreamConfig.default)(userConfig); | ||
const columnWidthIndex = Object.values(config.columns).map(column => { | ||
return column.width + column.paddingLeft + column.paddingRight; | ||
})); | ||
}); | ||
let empty; | ||
@@ -113,0 +106,0 @@ empty = true; |
@@ -8,8 +8,2 @@ "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")); | ||
@@ -23,2 +17,8 @@ | ||
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,4 +46,5 @@ * Merges user provided border characters with the default border ("honeywell") characters. | ||
const maximumColumnWidthIndex = (0, _calculateMaximumColumnWidthIndex.default)(rows); | ||
(0, _times2.default)(rows[0].length, index => { | ||
if ((0, _isUndefined2.default)(columns[index])) { | ||
for (let index = rows[0].length; index--;) { | ||
if (!columns[index]) { | ||
columns[index] = {}; | ||
@@ -60,3 +61,4 @@ } | ||
}, columnDefault, columns[index]); | ||
}); | ||
} | ||
return columns; | ||
@@ -76,3 +78,5 @@ }; | ||
(0, _validateConfig.default)('config.json', userConfig); | ||
const config = (0, _cloneDeep2.default)(userConfig); | ||
const config = _objectSpread({}, userConfig); | ||
config.border = makeBorder(config.border); | ||
@@ -79,0 +83,0 @@ config.columns = makeColumns(rows, config.columns, config.columnDefault); |
@@ -8,8 +8,2 @@ "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")); | ||
@@ -21,2 +15,8 @@ | ||
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,4 +43,6 @@ * Merges user provided border characters with the default border ("honeywell") characters. | ||
const makeColumns = (columnCount, columns = {}, columnDefault = {}) => { | ||
(0, _times2.default)(columnCount, index => { | ||
if ((0, _isUndefined2.default)(columns[index])) { | ||
let index = columnCount; | ||
while (index--) { | ||
if (!columns[index]) { | ||
columns[index] = {}; | ||
@@ -56,3 +58,4 @@ } | ||
}, columnDefault, columns[index]); | ||
}); | ||
} | ||
return columns; | ||
@@ -88,4 +91,5 @@ }; | ||
(0, _validateConfig.default)('streamConfig.json', userConfig); | ||
const config = (0, _cloneDeep2.default)(userConfig); | ||
const config = _objectSpread({}, userConfig); | ||
if (!config.columnDefault || !config.columnDefault.width) { | ||
@@ -92,0 +96,0 @@ throw new Error('Must provide config.columnDefault.width when creating a stream.'); |
@@ -8,6 +8,2 @@ "use strict"; | ||
var _flatten2 = _interopRequireDefault(require("lodash/flatten")); | ||
var _times2 = _interopRequireDefault(require("lodash/times")); | ||
var _wrapCell = _interopRequireDefault(require("./wrapCell")); | ||
@@ -26,3 +22,5 @@ | ||
const mappedRows = unmappedRows.map((cells, index0) => { | ||
const rowHeight = (0, _times2.default)(rowHeightIndex[index0], () => { | ||
const rowHeight = Array.from({ | ||
length: rowHeightIndex[index0] | ||
}, () => { | ||
return new Array(tableWidth).fill(''); | ||
@@ -40,4 +38,5 @@ }); // rowHeight | ||
return rowHeight; | ||
}); | ||
return (0, _flatten2.default)(mappedRows); | ||
}); // flat array | ||
return [].concat(...mappedRows); | ||
}; | ||
@@ -44,0 +43,0 @@ |
@@ -8,6 +8,5 @@ "use strict"; | ||
var _truncate2 = _interopRequireDefault(require("lodash/truncate")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const truncate = (string, length) => { | ||
return string.length > length ? string.slice(0, Math.max(0, length - 3)) + '...' : string; | ||
}; | ||
/** | ||
@@ -19,8 +18,8 @@ * @todo Make it work with ASCII content. | ||
*/ | ||
const truncateTableData = (rows, config) => { | ||
return rows.map(cells => { | ||
return cells.map((content, index) => { | ||
return (0, _truncate2.default)(content, { | ||
length: config.columns[index].truncate | ||
}); | ||
return truncate(content, config.columns[index].truncate); | ||
}); | ||
@@ -27,0 +26,0 @@ }); |
@@ -9,3 +9,2 @@ { | ||
"ajv": "^6.12.4", | ||
"lodash": "^4.17.20", | ||
"slice-ansi": "^4.0.0", | ||
@@ -25,3 +24,2 @@ "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", | ||
@@ -85,3 +83,3 @@ "chai": "^4.2.0", | ||
}, | ||
"version": "6.0.1" | ||
"version": "6.0.2" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
199513
3
23
2851
- Removedlodash@^4.17.20
- Removedlodash@4.17.21(transitive)