Comparing version 4.0.3 to 5.0.0
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,15 +6,11 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _lodash = require('lodash'); | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _stringWidth = _interopRequireDefault(require("string-width")); | ||
var _stringWidth = require('string-width'); | ||
var _stringWidth2 = _interopRequireDefault(_stringWidth); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const alignments = ['left', 'right', 'center']; | ||
/** | ||
@@ -25,6 +21,6 @@ * @param {string} subject | ||
*/ | ||
const alignLeft = (subject, width) => { | ||
return subject + ' '.repeat(width); | ||
}; | ||
/** | ||
@@ -35,6 +31,7 @@ * @param {string} subject | ||
*/ | ||
const alignRight = (subject, width) => { | ||
return ' '.repeat(width) + subject; | ||
}; | ||
/** | ||
@@ -45,5 +42,6 @@ * @param {string} subject | ||
*/ | ||
const alignCenter = (subject, width) => { | ||
let halfWidth; | ||
halfWidth = width / 2; | ||
@@ -55,7 +53,5 @@ | ||
halfWidth = Math.floor(halfWidth); | ||
return ' '.repeat(halfWidth) + subject + ' '.repeat(halfWidth + 1); | ||
} | ||
}; | ||
/** | ||
@@ -71,20 +67,20 @@ * Pads a string to the left and/or right to position the subject | ||
exports.default = (subject, containerWidth, alignment) => { | ||
if (!_lodash2.default.isString(subject)) { | ||
const alignString = (subject, containerWidth, alignment) => { | ||
if (!_lodash.default.isString(subject)) { | ||
throw new TypeError('Subject parameter value must be a string.'); | ||
} | ||
if (!_lodash2.default.isNumber(containerWidth)) { | ||
if (!_lodash.default.isNumber(containerWidth)) { | ||
throw new TypeError('Container width parameter value must be a number.'); | ||
} | ||
const subjectWidth = (0, _stringWidth2.default)(subject); | ||
const subjectWidth = (0, _stringWidth.default)(subject); | ||
if (subjectWidth > containerWidth) { | ||
// console.log('subjectWidth', subjectWidth, 'containerWidth', containerWidth, 'subject', subject); | ||
throw new Error('Subject parameter value width cannot be greater than the container width.'); | ||
} | ||
if (!_lodash2.default.isString(alignment)) { | ||
if (!_lodash.default.isString(alignment)) { | ||
throw new TypeError('Alignment parameter value must be a string.'); | ||
@@ -112,2 +108,6 @@ } | ||
return alignCenter(subject, availableWidth); | ||
}; | ||
}; | ||
var _default = alignString; | ||
exports.default = _default; | ||
//# sourceMappingURL=alignString.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,11 +6,8 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _stringWidth = require('string-width'); | ||
var _stringWidth = _interopRequireDefault(require("string-width")); | ||
var _stringWidth2 = _interopRequireDefault(_stringWidth); | ||
var _alignString = _interopRequireDefault(require("./alignString")); | ||
var _alignString = require('./alignString'); | ||
var _alignString2 = _interopRequireDefault(_alignString); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -23,3 +20,3 @@ | ||
*/ | ||
exports.default = (rows, config) => { | ||
const alignTableData = (rows, config) => { | ||
return rows.map(cells => { | ||
@@ -29,9 +26,13 @@ return cells.map((value, index1) => { | ||
if ((0, _stringWidth2.default)(value) === column.width) { | ||
if ((0, _stringWidth.default)(value) === column.width) { | ||
return value; | ||
} else { | ||
return (0, _alignString2.default)(value, column.width, column.alignment); | ||
return (0, _alignString.default)(value, column.width, column.alignment); | ||
} | ||
}); | ||
}); | ||
}; | ||
}; | ||
var _default = alignTableData; | ||
exports.default = _default; | ||
//# sourceMappingURL=alignTableData.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,15 +6,10 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _lodash = require('lodash'); | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _stringWidth = _interopRequireDefault(require("string-width")); | ||
var _stringWidth = require('string-width'); | ||
var _wrapWord = _interopRequireDefault(require("./wrapWord")); | ||
var _stringWidth2 = _interopRequireDefault(_stringWidth); | ||
var _wrapWord = require('./wrapWord'); | ||
var _wrapWord2 = _interopRequireDefault(_wrapWord); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -28,6 +23,4 @@ | ||
*/ | ||
exports.default = function (value, columnWidth) { | ||
let useWrapWord = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
if (!_lodash2.default.isString(value)) { | ||
const calculateCellHeight = (value, columnWidth, useWrapWord = false) => { | ||
if (!_lodash.default.isString(value)) { | ||
throw new TypeError('Value must be a string.'); | ||
@@ -45,6 +38,10 @@ } | ||
if (useWrapWord) { | ||
return (0, _wrapWord2.default)(value, columnWidth).length; | ||
return (0, _wrapWord.default)(value, columnWidth).length; | ||
} | ||
return Math.ceil((0, _stringWidth2.default)(value) / columnWidth); | ||
}; | ||
return Math.ceil((0, _stringWidth.default)(value) / columnWidth); | ||
}; | ||
var _default = calculateCellHeight; | ||
exports.default = _default; | ||
//# sourceMappingURL=calculateCellHeight.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _stringWidth = require('string-width'); | ||
var _stringWidth = _interopRequireDefault(require("string-width")); | ||
var _stringWidth2 = _interopRequireDefault(_stringWidth); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -20,6 +19,10 @@ | ||
*/ | ||
exports.default = cells => { | ||
const calculateCellWidthIndex = cells => { | ||
return cells.map(value => { | ||
return (0, _stringWidth2.default)(value); | ||
return (0, _stringWidth.default)(value); | ||
}); | ||
}; | ||
}; | ||
var _default = calculateCellWidthIndex; | ||
exports.default = _default; | ||
//# sourceMappingURL=calculateCellWidthIndex.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _calculateCellWidthIndex = require('./calculateCellWidthIndex'); | ||
var _calculateCellWidthIndex = _interopRequireDefault(require("./calculateCellWidthIndex")); | ||
var _calculateCellWidthIndex2 = _interopRequireDefault(_calculateCellWidthIndex); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -20,3 +19,3 @@ | ||
*/ | ||
exports.default = rows => { | ||
const calculateMaximumColumnWidthIndex = rows => { | ||
if (!rows[0]) { | ||
@@ -26,7 +25,5 @@ throw new Error('Dataset must have at least one row.'); | ||
const columns = Array(rows[0].length).fill(0); | ||
const columns = new Array(rows[0].length).fill(0); | ||
rows.forEach(row => { | ||
const columnWidthIndex = (0, _calculateCellWidthIndex2.default)(row); | ||
const columnWidthIndex = (0, _calculateCellWidthIndex.default)(row); | ||
columnWidthIndex.forEach((valueWidth, index0) => { | ||
@@ -38,4 +35,7 @@ if (columns[index0] < valueWidth) { | ||
}); | ||
return columns; | ||
}; | ||
return columns; | ||
}; | ||
var _default = calculateMaximumColumnWidthIndex; | ||
exports.default = _default; | ||
//# sourceMappingURL=calculateMaximumColumnWidthIndex.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,11 +6,8 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _lodash = require('lodash'); | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _calculateCellHeight = _interopRequireDefault(require("./calculateCellHeight")); | ||
var _calculateCellHeight = require('./calculateCellHeight'); | ||
var _calculateCellHeight2 = _interopRequireDefault(_calculateCellHeight); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -25,26 +22,25 @@ | ||
*/ | ||
exports.default = (rows, config) => { | ||
const calculateRowHeightIndex = (rows, config) => { | ||
const tableWidth = rows[0].length; | ||
const rowSpanIndex = []; | ||
rows.forEach(cells => { | ||
const cellHeightIndex = Array(tableWidth).fill(1); | ||
const cellHeightIndex = new Array(tableWidth).fill(1); | ||
cells.forEach((value, index1) => { | ||
if (!_lodash2.default.isNumber(config.columns[index1].width)) { | ||
if (!_lodash.default.isNumber(config.columns[index1].width)) { | ||
throw new TypeError('column[index].width must be a number.'); | ||
} | ||
if (!_lodash2.default.isBoolean(config.columns[index1].wrapWord)) { | ||
if (!_lodash.default.isBoolean(config.columns[index1].wrapWord)) { | ||
throw new TypeError('column[index].wrapWord must be a boolean.'); | ||
} | ||
cellHeightIndex[index1] = (0, _calculateCellHeight2.default)(value, config.columns[index1].width, config.columns[index1].wrapWord); | ||
cellHeightIndex[index1] = (0, _calculateCellHeight.default)(value, config.columns[index1].width, config.columns[index1].wrapWord); | ||
}); | ||
rowSpanIndex.push(_lodash2.default.max(cellHeightIndex)); | ||
rowSpanIndex.push(_lodash.default.max(cellHeightIndex)); | ||
}); | ||
return rowSpanIndex; | ||
}; | ||
return rowSpanIndex; | ||
}; | ||
var _default = calculateRowHeightIndex; | ||
exports.default = _default; | ||
//# sourceMappingURL=calculateRowHeightIndex.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,41 +6,24 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _lodash = require('lodash'); | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _makeStreamConfig = _interopRequireDefault(require("./makeStreamConfig")); | ||
var _makeStreamConfig = require('./makeStreamConfig'); | ||
var _drawRow = _interopRequireDefault(require("./drawRow")); | ||
var _makeStreamConfig2 = _interopRequireDefault(_makeStreamConfig); | ||
var _drawBorder = require("./drawBorder"); | ||
var _drawRow = require('./drawRow'); | ||
var _stringifyTableData = _interopRequireDefault(require("./stringifyTableData")); | ||
var _drawRow2 = _interopRequireDefault(_drawRow); | ||
var _truncateTableData = _interopRequireDefault(require("./truncateTableData")); | ||
var _drawBorder = require('./drawBorder'); | ||
var _mapDataUsingRowHeightIndex = _interopRequireDefault(require("./mapDataUsingRowHeightIndex")); | ||
var _stringifyTableData = require('./stringifyTableData'); | ||
var _alignTableData = _interopRequireDefault(require("./alignTableData")); | ||
var _stringifyTableData2 = _interopRequireDefault(_stringifyTableData); | ||
var _padTableData = _interopRequireDefault(require("./padTableData")); | ||
var _truncateTableData = require('./truncateTableData'); | ||
var _calculateRowHeightIndex = _interopRequireDefault(require("./calculateRowHeightIndex")); | ||
var _truncateTableData2 = _interopRequireDefault(_truncateTableData); | ||
var _mapDataUsingRowHeightIndex = require('./mapDataUsingRowHeightIndex'); | ||
var _mapDataUsingRowHeightIndex2 = _interopRequireDefault(_mapDataUsingRowHeightIndex); | ||
var _alignTableData = require('./alignTableData'); | ||
var _alignTableData2 = _interopRequireDefault(_alignTableData); | ||
var _padTableData = require('./padTableData'); | ||
var _padTableData2 = _interopRequireDefault(_padTableData); | ||
var _calculateRowHeightIndex = require('./calculateRowHeightIndex'); | ||
var _calculateRowHeightIndex2 = _interopRequireDefault(_calculateRowHeightIndex); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -55,16 +38,10 @@ | ||
let rows; | ||
rows = (0, _stringifyTableData2.default)(data); | ||
rows = (0, _truncateTableData2.default)(data, config); | ||
const rowHeightIndex = (0, _calculateRowHeightIndex2.default)(rows, config); | ||
rows = (0, _mapDataUsingRowHeightIndex2.default)(rows, rowHeightIndex, config); | ||
rows = (0, _alignTableData2.default)(rows, config); | ||
rows = (0, _padTableData2.default)(rows, config); | ||
rows = (0, _stringifyTableData.default)(data); | ||
rows = (0, _truncateTableData.default)(data, config); | ||
const rowHeightIndex = (0, _calculateRowHeightIndex.default)(rows, config); | ||
rows = (0, _mapDataUsingRowHeightIndex.default)(rows, rowHeightIndex, config); | ||
rows = (0, _alignTableData.default)(rows, config); | ||
rows = (0, _padTableData.default)(rows, config); | ||
return rows; | ||
}; | ||
/** | ||
@@ -76,22 +53,17 @@ * @param {string[]} row | ||
*/ | ||
const create = (row, columnWidthIndex, config) => { | ||
const rows = prepareData([row], config); | ||
const body = rows.map(literalRow => { | ||
return (0, _drawRow2.default)(literalRow, config.border); | ||
return (0, _drawRow.default)(literalRow, config.border); | ||
}).join(''); | ||
let output; | ||
output = ''; | ||
output += (0, _drawBorder.drawBorderTop)(columnWidthIndex, config.border); | ||
output += body; | ||
output += (0, _drawBorder.drawBorderBottom)(columnWidthIndex, config.border); | ||
output = _lodash2.default.trimEnd(output); | ||
output = _lodash.default.trimEnd(output); | ||
process.stdout.write(output); | ||
}; | ||
/** | ||
@@ -103,22 +75,17 @@ * @param {string[]} row | ||
*/ | ||
const append = (row, columnWidthIndex, config) => { | ||
const rows = prepareData([row], config); | ||
const body = rows.map(literalRow => { | ||
return (0, _drawRow2.default)(literalRow, config.border); | ||
return (0, _drawRow.default)(literalRow, config.border); | ||
}).join(''); | ||
let output; | ||
output = '\r\u001B[K'; | ||
output += (0, _drawBorder.drawBorderJoin)(columnWidthIndex, config.border); | ||
output += body; | ||
output += (0, _drawBorder.drawBorderBottom)(columnWidthIndex, config.border); | ||
output = _lodash2.default.trimEnd(output); | ||
output = _lodash.default.trimEnd(output); | ||
process.stdout.write(output); | ||
}; | ||
/** | ||
@@ -129,15 +96,10 @@ * @param {Object} userConfig | ||
exports.default = function () { | ||
let userConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
const config = (0, _makeStreamConfig2.default)(userConfig); | ||
const columnWidthIndex = _lodash2.default.mapValues(config.columns, column => { | ||
const createStream = (userConfig = {}) => { | ||
const config = (0, _makeStreamConfig.default)(userConfig); | ||
const columnWidthIndex = Object.values(_lodash.default.mapValues(config.columns, column => { | ||
return column.width + column.paddingLeft + column.paddingRight; | ||
}); | ||
})); | ||
let empty; | ||
empty = true; | ||
return { | ||
@@ -155,3 +117,2 @@ /** | ||
empty = false; | ||
return create(row, columnWidthIndex, config); | ||
@@ -163,2 +124,6 @@ } else { | ||
}; | ||
}; | ||
}; | ||
var _default = createStream; | ||
exports.default = _default; | ||
//# sourceMappingURL=createStream.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,2 +6,4 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.drawBorderTop = exports.drawBorderJoin = exports.drawBorderBottom = exports.drawBorder = void 0; | ||
/** | ||
@@ -24,6 +26,4 @@ * @typedef drawBorder~parts | ||
}).join(parts.join); | ||
return parts.left + columns + parts.right + '\n'; | ||
}; | ||
/** | ||
@@ -42,2 +42,6 @@ * @typedef drawBorderTop~parts | ||
*/ | ||
exports.drawBorder = drawBorder; | ||
const drawBorderTop = (columnSizeIndex, parts) => { | ||
@@ -51,3 +55,2 @@ return drawBorder(columnSizeIndex, { | ||
}; | ||
/** | ||
@@ -66,2 +69,6 @@ * @typedef drawBorderJoin~parts | ||
*/ | ||
exports.drawBorderTop = drawBorderTop; | ||
const drawBorderJoin = (columnSizeIndex, parts) => { | ||
@@ -75,3 +82,2 @@ return drawBorder(columnSizeIndex, { | ||
}; | ||
/** | ||
@@ -90,2 +96,6 @@ * @typedef drawBorderBottom~parts | ||
*/ | ||
exports.drawBorderJoin = drawBorderJoin; | ||
const drawBorderBottom = (columnSizeIndex, parts) => { | ||
@@ -100,5 +110,3 @@ return drawBorder(columnSizeIndex, { | ||
exports.drawBorder = drawBorder; | ||
exports.drawBorderBottom = drawBorderBottom; | ||
exports.drawBorderJoin = drawBorderJoin; | ||
exports.drawBorderTop = drawBorderTop; | ||
//# sourceMappingURL=drawBorder.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,2 +6,3 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
@@ -20,4 +21,8 @@ /** | ||
*/ | ||
exports.default = (columns, border) => { | ||
const drawRow = (columns, border) => { | ||
return border.bodyLeft + columns.join(border.bodyJoin) + border.bodyRight + '\n'; | ||
}; | ||
}; | ||
var _default = drawRow; | ||
exports.default = _default; | ||
//# sourceMappingURL=drawRow.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,9 +6,8 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _drawBorder = require('./drawBorder'); | ||
var _drawBorder = require("./drawBorder"); | ||
var _drawRow = require('./drawRow'); | ||
var _drawRow = _interopRequireDefault(require("./drawRow")); | ||
var _drawRow2 = _interopRequireDefault(_drawRow); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -24,11 +23,8 @@ | ||
*/ | ||
exports.default = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => { | ||
const drawTable = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => { | ||
let output; | ||
let realRowIndex; | ||
let rowHeight; | ||
const rowCount = rows.length; | ||
realRowIndex = 0; | ||
output = ''; | ||
@@ -41,7 +37,6 @@ | ||
rows.forEach((row, index0) => { | ||
output += (0, _drawRow2.default)(row, border); | ||
output += (0, _drawRow.default)(row, border); | ||
if (!rowHeight) { | ||
rowHeight = rowSpanIndex[realRowIndex]; | ||
realRowIndex++; | ||
@@ -62,2 +57,6 @@ } | ||
return output; | ||
}; | ||
}; | ||
var _default = drawTable; | ||
exports.default = _default; | ||
//# sourceMappingURL=drawTable.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,2 +6,3 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
@@ -33,3 +34,3 @@ /* eslint-disable sort-keys */ | ||
*/ | ||
exports.default = name => { | ||
const getBorderCharacters = name => { | ||
if (name === 'honeywell') { | ||
@@ -41,3 +42,2 @@ return { | ||
topRight: '╗', | ||
bottomBody: '═', | ||
@@ -47,7 +47,5 @@ bottomJoin: '╧', | ||
bottomRight: '╝', | ||
bodyLeft: '║', | ||
bodyRight: '║', | ||
bodyJoin: '│', | ||
joinBody: '─', | ||
@@ -66,3 +64,2 @@ joinLeft: '╟', | ||
topRight: '┐', | ||
bottomBody: '─', | ||
@@ -72,7 +69,5 @@ bottomJoin: '┴', | ||
bottomRight: '┘', | ||
bodyLeft: '│', | ||
bodyRight: '│', | ||
bodyJoin: '│', | ||
joinBody: '─', | ||
@@ -91,3 +86,2 @@ joinLeft: '├', | ||
topRight: '+', | ||
bottomBody: '-', | ||
@@ -97,7 +91,5 @@ bottomJoin: '+', | ||
bottomRight: '+', | ||
bodyLeft: '|', | ||
bodyRight: '|', | ||
bodyJoin: '|', | ||
joinBody: '-', | ||
@@ -116,3 +108,2 @@ joinLeft: '|', | ||
topRight: '', | ||
bottomBody: '', | ||
@@ -122,7 +113,5 @@ bottomJoin: '', | ||
bottomRight: '', | ||
bodyLeft: '', | ||
bodyRight: '', | ||
bodyJoin: '', | ||
joinBody: '', | ||
@@ -136,2 +125,6 @@ joinLeft: '', | ||
throw new Error('Unknown border template "' + name + '".'); | ||
}; | ||
}; | ||
var _default = getBorderCharacters; | ||
exports.default = _default; | ||
//# sourceMappingURL=getBorderCharacters.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,20 +6,28 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.getBorderCharacters = exports.createStream = exports.table = undefined; | ||
Object.defineProperty(exports, "table", { | ||
enumerable: true, | ||
get: function get() { | ||
return _table.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "createStream", { | ||
enumerable: true, | ||
get: function get() { | ||
return _createStream.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "getBorderCharacters", { | ||
enumerable: true, | ||
get: function get() { | ||
return _getBorderCharacters.default; | ||
} | ||
}); | ||
var _table = require('./table'); | ||
var _table = _interopRequireDefault(require("./table")); | ||
var _table2 = _interopRequireDefault(_table); | ||
var _createStream = _interopRequireDefault(require("./createStream")); | ||
var _createStream = require('./createStream'); | ||
var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters")); | ||
var _createStream2 = _interopRequireDefault(_createStream); | ||
var _getBorderCharacters = require('./getBorderCharacters'); | ||
var _getBorderCharacters2 = _interopRequireDefault(_getBorderCharacters); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.table = _table2.default; | ||
exports.createStream = _createStream2.default; | ||
exports.getBorderCharacters = _getBorderCharacters2.default; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,19 +6,12 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _lodash = require('lodash'); | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters")); | ||
var _getBorderCharacters = require('./getBorderCharacters'); | ||
var _validateConfig = _interopRequireDefault(require("./validateConfig")); | ||
var _getBorderCharacters2 = _interopRequireDefault(_getBorderCharacters); | ||
var _calculateMaximumColumnWidthIndex = _interopRequireDefault(require("./calculateMaximumColumnWidthIndex")); | ||
var _validateConfig = require('./validateConfig'); | ||
var _validateConfig2 = _interopRequireDefault(_validateConfig); | ||
var _calculateMaximumColumnWidthIndex = require('./calculateMaximumColumnWidthIndex'); | ||
var _calculateMaximumColumnWidthIndex2 = _interopRequireDefault(_calculateMaximumColumnWidthIndex); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -32,8 +25,5 @@ | ||
*/ | ||
const makeBorder = function makeBorder() { | ||
let border = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return Object.assign({}, (0, _getBorderCharacters2.default)('honeywell'), border); | ||
const makeBorder = (border = {}) => { | ||
return Object.assign({}, (0, _getBorderCharacters.default)('honeywell'), border); | ||
}; | ||
/** | ||
@@ -48,10 +38,9 @@ * Creates a configuration for every column using default | ||
*/ | ||
const makeColumns = function makeColumns(rows) { | ||
let columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
let columnDefault = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
const maximumColumnWidthIndex = (0, _calculateMaximumColumnWidthIndex2.default)(rows); | ||
_lodash2.default.times(rows[0].length, index => { | ||
if (_lodash2.default.isUndefined(columns[index])) { | ||
const makeColumns = (rows, columns = {}, columnDefault = {}) => { | ||
const maximumColumnWidthIndex = (0, _calculateMaximumColumnWidthIndex.default)(rows); | ||
_lodash.default.times(rows[0].length, index => { | ||
if (_lodash.default.isUndefined(columns[index])) { | ||
columns[index] = {}; | ||
@@ -72,3 +61,2 @@ } | ||
}; | ||
/** | ||
@@ -83,8 +71,7 @@ * Makes a new configuration object out of the userConfig object | ||
exports.default = function (rows) { | ||
let userConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
(0, _validateConfig2.default)('config.json', userConfig); | ||
const makeConfig = (rows, userConfig = {}) => { | ||
(0, _validateConfig.default)('config.json', userConfig); | ||
const config = _lodash2.default.cloneDeep(userConfig); | ||
const config = _lodash.default.cloneDeep(userConfig); | ||
@@ -104,2 +91,6 @@ config.border = makeBorder(config.border); | ||
return config; | ||
}; | ||
}; | ||
var _default = makeConfig; | ||
exports.default = _default; | ||
//# sourceMappingURL=makeConfig.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,15 +6,10 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _lodash = require('lodash'); | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters")); | ||
var _getBorderCharacters = require('./getBorderCharacters'); | ||
var _validateConfig = _interopRequireDefault(require("./validateConfig")); | ||
var _getBorderCharacters2 = _interopRequireDefault(_getBorderCharacters); | ||
var _validateConfig = require('./validateConfig'); | ||
var _validateConfig2 = _interopRequireDefault(_validateConfig); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -28,8 +23,5 @@ | ||
*/ | ||
const makeBorder = function makeBorder() { | ||
let border = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return Object.assign({}, (0, _getBorderCharacters2.default)('honeywell'), border); | ||
const makeBorder = (border = {}) => { | ||
return Object.assign({}, (0, _getBorderCharacters.default)('honeywell'), border); | ||
}; | ||
/** | ||
@@ -44,8 +36,7 @@ * Creates a configuration for every column using default | ||
*/ | ||
const makeColumns = function makeColumns(columnCount) { | ||
let columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
let columnDefault = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
_lodash2.default.times(columnCount, index => { | ||
if (_lodash2.default.isUndefined(columns[index])) { | ||
const makeColumns = (columnCount, columns = {}, columnDefault = {}) => { | ||
_lodash.default.times(columnCount, index => { | ||
if (_lodash.default.isUndefined(columns[index])) { | ||
columns[index] = {}; | ||
@@ -65,3 +56,2 @@ } | ||
}; | ||
/** | ||
@@ -92,8 +82,7 @@ * @typedef {Object} columnConfig | ||
exports.default = function () { | ||
let userConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
(0, _validateConfig2.default)('streamConfig.json', userConfig); | ||
const makeStreamConfig = (userConfig = {}) => { | ||
(0, _validateConfig.default)('streamConfig.json', userConfig); | ||
const config = _lodash2.default.cloneDeep(userConfig); | ||
const config = _lodash.default.cloneDeep(userConfig); | ||
@@ -110,4 +99,7 @@ if (!config.columnDefault || !config.columnDefault.width) { | ||
config.columns = makeColumns(config.columnCount, config.columns, config.columnDefault); | ||
return config; | ||
}; | ||
return config; | ||
}; | ||
var _default = makeStreamConfig; | ||
exports.default = _default; | ||
//# sourceMappingURL=makeStreamConfig.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,15 +6,10 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _lodash = require('lodash'); | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _wrapString = _interopRequireDefault(require("./wrapString")); | ||
var _wrapString = require('./wrapString'); | ||
var _wrapWord = _interopRequireDefault(require("./wrapWord")); | ||
var _wrapString2 = _interopRequireDefault(_wrapString); | ||
var _wrapWord = require('./wrapWord'); | ||
var _wrapWord2 = _interopRequireDefault(_wrapWord); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -28,14 +23,12 @@ | ||
*/ | ||
exports.default = (unmappedRows, rowHeightIndex, config) => { | ||
const mapDataUsingRowHeightIndex = (unmappedRows, rowHeightIndex, config) => { | ||
const tableWidth = unmappedRows[0].length; | ||
const mappedRows = unmappedRows.map((cells, index0) => { | ||
const rowHeight = _lodash2.default.times(rowHeightIndex[index0], () => { | ||
return Array(tableWidth).fill(''); | ||
}); | ||
// rowHeight | ||
const rowHeight = _lodash.default.times(rowHeightIndex[index0], () => { | ||
return new Array(tableWidth).fill(''); | ||
}); // rowHeight | ||
// [{row index within rowSaw; index2}] | ||
// [{cell index within a virtual row; index1}] | ||
cells.forEach((value, index1) => { | ||
@@ -45,5 +38,5 @@ let chunkedValue; | ||
if (config.columns[index1].wrapWord) { | ||
chunkedValue = (0, _wrapWord2.default)(value, config.columns[index1].width); | ||
chunkedValue = (0, _wrapWord.default)(value, config.columns[index1].width); | ||
} else { | ||
chunkedValue = (0, _wrapString2.default)(value, config.columns[index1].width); | ||
chunkedValue = (0, _wrapString.default)(value, config.columns[index1].width); | ||
} | ||
@@ -55,7 +48,9 @@ | ||
}); | ||
return rowHeight; | ||
}); | ||
return _lodash.default.flatten(mappedRows); | ||
}; | ||
return _lodash2.default.flatten(mappedRows); | ||
}; | ||
var _default = mapDataUsingRowHeightIndex; | ||
exports.default = _default; | ||
//# sourceMappingURL=mapDataUsingRowHeightIndex.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,2 +6,3 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
@@ -13,10 +14,13 @@ /** | ||
*/ | ||
exports.default = (rows, config) => { | ||
const padTableData = (rows, config) => { | ||
return rows.map(cells => { | ||
return cells.map((value, index1) => { | ||
const column = config.columns[index1]; | ||
return ' '.repeat(column.paddingLeft) + value + ' '.repeat(column.paddingRight); | ||
}); | ||
}); | ||
}; | ||
}; | ||
var _default = padTableData; | ||
exports.default = _default; | ||
//# sourceMappingURL=padTableData.js.map |
{ | ||
"$id": "config.json", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
@@ -5,0 +5,0 @@ "properties": { |
{ | ||
"$id": "streamConfig.json", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
@@ -5,0 +5,0 @@ "properties": { |
@@ -6,2 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
@@ -14,6 +15,10 @@ /** | ||
*/ | ||
exports.default = rows => { | ||
const stringifyTableData = rows => { | ||
return rows.map(cells => { | ||
return cells.map(String); | ||
}); | ||
}; | ||
}; | ||
var _default = stringifyTableData; | ||
exports.default = _default; | ||
//# sourceMappingURL=stringifyTableData.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,43 +6,24 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _drawTable = require('./drawTable'); | ||
var _drawTable = _interopRequireDefault(require("./drawTable")); | ||
var _drawTable2 = _interopRequireDefault(_drawTable); | ||
var _calculateCellWidthIndex = _interopRequireDefault(require("./calculateCellWidthIndex")); | ||
var _calculateCellWidthIndex = require('./calculateCellWidthIndex'); | ||
var _makeConfig = _interopRequireDefault(require("./makeConfig")); | ||
var _calculateCellWidthIndex2 = _interopRequireDefault(_calculateCellWidthIndex); | ||
var _calculateRowHeightIndex = _interopRequireDefault(require("./calculateRowHeightIndex")); | ||
var _makeConfig = require('./makeConfig'); | ||
var _mapDataUsingRowHeightIndex = _interopRequireDefault(require("./mapDataUsingRowHeightIndex")); | ||
var _makeConfig2 = _interopRequireDefault(_makeConfig); | ||
var _alignTableData = _interopRequireDefault(require("./alignTableData")); | ||
var _calculateRowHeightIndex = require('./calculateRowHeightIndex'); | ||
var _padTableData = _interopRequireDefault(require("./padTableData")); | ||
var _calculateRowHeightIndex2 = _interopRequireDefault(_calculateRowHeightIndex); | ||
var _validateTableData = _interopRequireDefault(require("./validateTableData")); | ||
var _mapDataUsingRowHeightIndex = require('./mapDataUsingRowHeightIndex'); | ||
var _stringifyTableData = _interopRequireDefault(require("./stringifyTableData")); | ||
var _mapDataUsingRowHeightIndex2 = _interopRequireDefault(_mapDataUsingRowHeightIndex); | ||
var _truncateTableData = _interopRequireDefault(require("./truncateTableData")); | ||
var _alignTableData = require('./alignTableData'); | ||
var _alignTableData2 = _interopRequireDefault(_alignTableData); | ||
var _padTableData = require('./padTableData'); | ||
var _padTableData2 = _interopRequireDefault(_padTableData); | ||
var _validateTableData = require('./validateTableData'); | ||
var _validateTableData2 = _interopRequireDefault(_validateTableData); | ||
var _stringifyTableData = require('./stringifyTableData'); | ||
var _stringifyTableData2 = _interopRequireDefault(_stringifyTableData); | ||
var _truncateTableData = require('./truncateTableData'); | ||
var _truncateTableData2 = _interopRequireDefault(_truncateTableData); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -63,2 +44,3 @@ | ||
* @property {number} truncate Number of characters are which the content will be truncated (default: Infinity). | ||
* @property {boolean} wrapWord When true the text is broken at the nearest space or one of the special characters | ||
* @property {number} paddingLeft Cell content padding width left (default: 1). | ||
@@ -113,24 +95,18 @@ * @property {number} paddingRight Cell content padding width right (default: 1). | ||
*/ | ||
exports.default = function (data) { | ||
let userConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
const table = (data, userConfig = {}) => { | ||
let rows; | ||
(0, _validateTableData.default)(data); | ||
rows = (0, _stringifyTableData.default)(data); | ||
const config = (0, _makeConfig.default)(rows, userConfig); | ||
rows = (0, _truncateTableData.default)(data, config); | ||
const rowHeightIndex = (0, _calculateRowHeightIndex.default)(rows, config); | ||
rows = (0, _mapDataUsingRowHeightIndex.default)(rows, rowHeightIndex, config); | ||
rows = (0, _alignTableData.default)(rows, config); | ||
rows = (0, _padTableData.default)(rows, config); | ||
const cellWidthIndex = (0, _calculateCellWidthIndex.default)(rows[0]); | ||
return (0, _drawTable.default)(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine); | ||
}; | ||
(0, _validateTableData2.default)(data); | ||
rows = (0, _stringifyTableData2.default)(data); | ||
const config = (0, _makeConfig2.default)(rows, userConfig); | ||
rows = (0, _truncateTableData2.default)(data, config); | ||
const rowHeightIndex = (0, _calculateRowHeightIndex2.default)(rows, config); | ||
rows = (0, _mapDataUsingRowHeightIndex2.default)(rows, rowHeightIndex, config); | ||
rows = (0, _alignTableData2.default)(rows, config); | ||
rows = (0, _padTableData2.default)(rows, config); | ||
const cellWidthIndex = (0, _calculateCellWidthIndex2.default)(rows[0]); | ||
return (0, _drawTable2.default)(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine); | ||
}; | ||
var _default = table; | ||
exports.default = _default; | ||
//# sourceMappingURL=table.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _lodash = require('lodash'); | ||
var _lodash = _interopRequireDefault(require("lodash")); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -20,6 +19,6 @@ | ||
*/ | ||
exports.default = (rows, config) => { | ||
const truncateTableData = (rows, config) => { | ||
return rows.map(cells => { | ||
return cells.map((content, index) => { | ||
return _lodash2.default.truncate(content, { | ||
return _lodash.default.truncate(content, { | ||
length: config.columns[index].truncate | ||
@@ -29,2 +28,6 @@ }); | ||
}); | ||
}; | ||
}; | ||
var _default = truncateTableData; | ||
exports.default = _default; | ||
//# sourceMappingURL=truncateTableData.js.map |
@@ -17,3 +17,3 @@ 'use strict'; | ||
for (var key0 in data) { | ||
var isAdditional0 = !(false || validate.schema.properties[key0]); | ||
var isAdditional0 = !(false || validate.schema.properties.hasOwnProperty(key0)); | ||
if (isAdditional0) { | ||
@@ -348,3 +348,3 @@ valid1 = false; | ||
for (var key0 in data) { | ||
var isAdditional0 = !(false || validate.schema.properties[key0]); | ||
var isAdditional0 = !(false || key0 == 'alignment' || key0 == 'width' || key0 == 'wrapWord' || key0 == 'truncate' || key0 == 'paddingLeft' || key0 == 'paddingRight'); | ||
if (isAdditional0) { | ||
@@ -646,3 +646,3 @@ valid1 = false; | ||
"$id": "config.json", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
@@ -649,0 +649,0 @@ "properties": { |
@@ -17,3 +17,3 @@ 'use strict'; | ||
for (var key0 in data) { | ||
var isAdditional0 = !(false || validate.schema.properties[key0]); | ||
var isAdditional0 = !(false || validate.schema.properties.hasOwnProperty(key0)); | ||
if (isAdditional0) { | ||
@@ -348,3 +348,3 @@ valid1 = false; | ||
for (var key0 in data) { | ||
var isAdditional0 = !(false || validate.schema.properties[key0]); | ||
var isAdditional0 = !(false || key0 == 'alignment' || key0 == 'width' || key0 == 'wrapWord' || key0 == 'truncate' || key0 == 'paddingLeft' || key0 == 'paddingRight'); | ||
if (isAdditional0) { | ||
@@ -633,3 +633,3 @@ valid1 = false; | ||
"$id": "streamConfig.json", | ||
"$schema": "http://json-schema.org/draft-06/schema#", | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "object", | ||
@@ -636,0 +636,0 @@ "properties": { |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,2 +6,3 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
@@ -20,3 +21,3 @@ /** | ||
*/ | ||
exports.default = rows => { | ||
const validateTableData = rows => { | ||
if (!Array.isArray(rows)) { | ||
@@ -35,20 +36,66 @@ throw new TypeError('Table data must be an array.'); | ||
const columnNumber = rows[0].length; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
for (const cells of rows) { | ||
if (!Array.isArray(cells)) { | ||
throw new TypeError('Table row data must be an array.'); | ||
} | ||
try { | ||
for (var _iterator = rows[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
const cells = _step.value; | ||
if (cells.length !== columnNumber) { | ||
throw new Error('Table must have a consistent number of cells.'); | ||
} | ||
if (!Array.isArray(cells)) { | ||
throw new TypeError('Table row data must be an array.'); | ||
} | ||
// @todo Make an exception for newline characters. | ||
// @see https://github.com/gajus/table/issues/9 | ||
for (const cell of cells) { | ||
if (/[\u0001-\u001A]/.test(cell)) { | ||
throw new Error('Table data must not contain control characters.'); | ||
if (cells.length !== columnNumber) { | ||
throw new Error('Table must have a consistent number of cells.'); | ||
} // @todo Make an exception for newline characters. | ||
// @see https://github.com/gajus/table/issues/9 | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator2 = cells[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
const cell = _step2.value; | ||
// eslint-disable-next-line no-control-regex | ||
if (/[\u0001-\u001A]/.test(cell)) { | ||
throw new Error('Table data must not contain control characters.'); | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) { | ||
_iterator2.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
}; | ||
}; | ||
var _default = validateTableData; | ||
exports.default = _default; | ||
//# sourceMappingURL=validateTableData.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,11 +6,8 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _sliceAnsi = require('slice-ansi'); | ||
var _sliceAnsi = _interopRequireDefault(require("slice-ansi")); | ||
var _sliceAnsi2 = _interopRequireDefault(_sliceAnsi); | ||
var _stringWidth = _interopRequireDefault(require("string-width")); | ||
var _stringWidth = require('string-width'); | ||
var _stringWidth2 = _interopRequireDefault(_stringWidth); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -29,16 +26,17 @@ | ||
*/ | ||
exports.default = (subject, size) => { | ||
const wrapString = (subject, size) => { | ||
let subjectSlice; | ||
subjectSlice = subject; | ||
const chunks = []; | ||
do { | ||
chunks.push((0, _sliceAnsi2.default)(subjectSlice, 0, size)); | ||
chunks.push((0, _sliceAnsi.default)(subjectSlice, 0, size)); | ||
subjectSlice = (0, _sliceAnsi.default)(subjectSlice, size).trim(); | ||
} while ((0, _stringWidth.default)(subjectSlice)); | ||
subjectSlice = (0, _sliceAnsi2.default)(subjectSlice, size).trim(); | ||
} while ((0, _stringWidth2.default)(subjectSlice)); | ||
return chunks; | ||
}; | ||
return chunks; | ||
}; | ||
var _default = wrapString; | ||
exports.default = _default; | ||
//# sourceMappingURL=wrapString.js.map |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,11 +6,8 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _sliceAnsi = require('slice-ansi'); | ||
var _sliceAnsi = _interopRequireDefault(require("slice-ansi")); | ||
var _sliceAnsi2 = _interopRequireDefault(_sliceAnsi); | ||
var _stringWidth = _interopRequireDefault(require("string-width")); | ||
var _stringWidth = require('string-width'); | ||
var _stringWidth2 = _interopRequireDefault(_stringWidth); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -23,10 +20,7 @@ | ||
*/ | ||
exports.default = (input, size) => { | ||
const wrapWord = (input, size) => { | ||
let subject; | ||
subject = input; | ||
const chunks = []; // https://regex101.com/r/gY5kZ1/1 | ||
const chunks = []; | ||
// https://regex101.com/r/gY5kZ1/1 | ||
const re = new RegExp('(^.{1,' + size + '}(\\s+|$))|(^.{1,' + (size - 1) + '}(\\\\|/|_|\\.|,|;|-))'); | ||
@@ -36,3 +30,2 @@ | ||
let chunk; | ||
chunk = subject.match(re); | ||
@@ -42,15 +35,17 @@ | ||
chunk = chunk[0]; | ||
subject = (0, _sliceAnsi2.default)(subject, (0, _stringWidth2.default)(chunk)); | ||
subject = (0, _sliceAnsi.default)(subject, (0, _stringWidth.default)(chunk)); | ||
chunk = chunk.trim(); | ||
} else { | ||
chunk = (0, _sliceAnsi2.default)(subject, 0, size); | ||
subject = (0, _sliceAnsi2.default)(subject, size); | ||
chunk = (0, _sliceAnsi.default)(subject, 0, size); | ||
subject = (0, _sliceAnsi.default)(subject, size); | ||
} | ||
chunks.push(chunk); | ||
} while ((0, _stringWidth2.default)(subject)); | ||
} while ((0, _stringWidth.default)(subject)); | ||
return chunks; | ||
}; | ||
}; | ||
var _default = wrapWord; | ||
exports.default = _default; | ||
//# sourceMappingURL=wrapWord.js.map |
@@ -8,6 +8,4 @@ { | ||
"dependencies": { | ||
"ajv": "^6.0.1", | ||
"ajv-keywords": "^3.0.0", | ||
"chalk": "^2.1.0", | ||
"lodash": "^4.17.4", | ||
"ajv": "^6.5.3", | ||
"lodash": "^4.17.10", | ||
"slice-ansi": "1.0.0", | ||
@@ -18,21 +16,35 @@ "string-width": "^2.1.1" | ||
"devDependencies": { | ||
"@babel/cli": "^7.0.0", | ||
"@babel/core": "^7.0.0", | ||
"@babel/node": "^7.0.0", | ||
"@babel/plugin-transform-flow-strip-types": "^7.0.0", | ||
"@babel/preset-env": "^7.0.0", | ||
"@babel/register": "^7.0.0", | ||
"ajv-cli": "^3.0.0", | ||
"babel": "^6.23.0", | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.0", | ||
"babel-plugin-istanbul": "^4.1.5", | ||
"babel-preset-es2015-node4": "^2.1.1", | ||
"babel-register": "^6.26.0", | ||
"ajv-keywords": "^3.2.0", | ||
"babel-plugin-istanbul": "^5.0.1", | ||
"babel-plugin-transform-export-default-name": "^2.0.4", | ||
"chai": "^4.1.2", | ||
"eslint": "^4.7.2", | ||
"eslint-config-canonical": "^9.3.1", | ||
"gitdown": "^2.5.1", | ||
"husky": "^0.14.3", | ||
"mocha": "^5.0.0", | ||
"nyc": "^11.2.1", | ||
"sinon": "^4.0.0" | ||
"chalk": "^2.4.1", | ||
"coveralls": "^3.0.2", | ||
"eslint": "^5.5.0", | ||
"eslint-config-canonical": "^12.0.0", | ||
"flow-bin": "^0.80.0", | ||
"flow-copy-source": "^2.0.2", | ||
"gitdown": "^2.5.3", | ||
"husky": "^1.0.0-rc.13", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.0.1", | ||
"semantic-release": "^15.9.12", | ||
"sinon": "^6.1.5" | ||
}, | ||
"engines": { | ||
"node": ">=4.0.0" | ||
"node": ">=8.0.0" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"post-commit": "npm run create-readme && git add README.md && git commit -m 'docs: generate docs' --no-verify", | ||
"pre-commit": "npm run lint && npm run test && npm run build" | ||
} | ||
}, | ||
"keywords": [ | ||
@@ -50,8 +62,10 @@ "ascii", | ||
"include": [ | ||
"src/*.js" | ||
"src/**/*.js" | ||
], | ||
"instrument": false, | ||
"lines": 70, | ||
"reporter": [ | ||
"text-lcov" | ||
], | ||
"require": [ | ||
"babel-register" | ||
"@babel/register" | ||
], | ||
@@ -65,11 +79,9 @@ "sourceMap": false | ||
"scripts": { | ||
"build": "rm -fr ./dist && NODE_ENV=production babel --copy-files ./src --out-dir ./dist && npm run make-validators", | ||
"lint": "npm run build && eslint ./src ./tests", | ||
"make-readme": "gitdown ./.README/README.md --output-file ./README.md", | ||
"make-validators": "ajv compile --all-errors --inline-refs=false -s src/schemas/config -c ajv-keywords/keywords/typeof -o dist/validateConfig.js && ajv compile --all-errors --inline-refs=false -s src/schemas/streamConfig -c ajv-keywords/keywords/typeof -o dist/validateStreamConfig.js", | ||
"precommit": "npm run lint && npm run test", | ||
"prepublish": "NODE_ENV=production npm run build", | ||
"test": "npm run build && nyc --check-coverage mocha" | ||
"build": "rm -fr ./dist && NODE_ENV=production babel ./src --out-dir ./dist --copy-files --source-maps && npm run create-validators && flow-copy-source src dist", | ||
"create-readme": "gitdown ./.README/README.md --output-file ./README.md", | ||
"create-validators": "ajv compile --all-errors --inline-refs=false -s src/schemas/config -c ajv-keywords/keywords/typeof -o dist/validateConfig.js && ajv compile --all-errors --inline-refs=false -s src/schemas/streamConfig -c ajv-keywords/keywords/typeof -o dist/validateStreamConfig.js", | ||
"lint": "npm run build && eslint ./src ./test && flow", | ||
"test": "mocha --require @babel/register" | ||
}, | ||
"version": "4.0.3" | ||
"version": "5.0.0" | ||
} |
<a name="table"></a> | ||
# Table | ||
[![Travis build status](http://img.shields.io/travis/gajus/table/master.svg?style=flat)](https://travis-ci.org/gajus/table) | ||
[![NPM version](http://img.shields.io/npm/v/table.svg?style=flat)](https://www.npmjs.com/package/table) | ||
[![js-canonical-style](https://img.shields.io/badge/code%20style-canonical-brightgreen.svg?style=flat)](https://github.com/gajus/canonical) | ||
[![Travis build status](http://img.shields.io/travis/gajus/table/master.svg?style=flat-square)](https://travis-ci.org/gajus/table) | ||
[![Coveralls](https://img.shields.io/coveralls/gajus/table.svg?style=flat-square)](https://coveralls.io/github/gajus/table) | ||
[![NPM version](http://img.shields.io/npm/v/table.svg?style=flat-square)](https://www.npmjs.org/package/table) | ||
[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical) | ||
[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social&label=Follow)](https://twitter.com/kuizinas) | ||
@@ -99,3 +101,3 @@ * [Table](#table) | ||
* | ||
* @typedef {function} drawJoin | ||
* @typedef {function} drawHorizontalLine | ||
* @param {number} index | ||
@@ -111,3 +113,3 @@ * @param {number} size | ||
* @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values. | ||
* @property {table~drawJoin} drawHorizontalLine | ||
* @property {table~drawHorizontalLine} drawHorizontalLine | ||
*/ | ||
@@ -301,3 +303,3 @@ | ||
/** | ||
* @typedef {function} drawJoin | ||
* @typedef {function} drawHorizontalLine | ||
* @param {number} index | ||
@@ -315,2 +317,3 @@ * @param {number} size | ||
console.log(output); | ||
``` | ||
@@ -328,2 +331,3 @@ | ||
╚════╧════╧════╝ | ||
``` | ||
@@ -330,0 +334,0 @@ |
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
190074
4
75
2818
676
23
- Removedajv-keywords@^3.0.0
- Removedchalk@^2.1.0
- Removedajv-keywords@3.5.2(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedsupports-color@5.5.0(transitive)
Updatedajv@^6.5.3
Updatedlodash@^4.17.10