๐Ÿš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more โ†’
Socket
Book a DemoInstallSign in
Socket

table

Package Overview
Dependencies
Maintainers
1
Versions
87
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

to
3.5.0

.README/usage/draw_horizontal_line.md

2

.README/README.md

@@ -28,3 +28,3 @@ # Table

{"gitdown": "include", "file": "./usage/custom_border.md"}
{"gitdown": "include", "file": "./usage/draw_join.md"}
{"gitdown": "include", "file": "./usage/draw_horizontal_line.md"}
{"gitdown": "include", "file": "./usage/padding_cell_content.md"}

@@ -31,0 +31,0 @@ {"gitdown": "include", "file": "./usage/predefined_border_templates.md"}

@@ -68,3 +68,3 @@ ## Usage

* @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values.
* @property {table~drawJoin} drawJoin
* @property {table~drawJoin} drawHorizontalLine
*/

@@ -71,0 +71,0 @@

@@ -23,6 +23,6 @@ 'use strict';

* @param {Array} rowSpanIndex
* @param {function} drawJoin
* @param {function} drawHorizontalLine
*/
exports['default'] = function (rows, border, columnSizeIndex, rowSpanIndex, drawJoin) {
exports['default'] = function (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) {
var output = undefined,

@@ -38,4 +38,7 @@ rowCount = undefined,

output = '';
output += (0, _drawBorder.drawBorderTop)(columnSizeIndex, border);
if (drawHorizontalLine(realRowIndex, rowCount)) {
output += (0, _drawBorder.drawBorderTop)(columnSizeIndex, border);
}
_lodash2['default'].forEach(rows, function (row, i) {

@@ -52,3 +55,3 @@ output += (0, _drawRow2['default'])(row, border);

if (rowHeight === 0 && i !== rowCount - 1 && drawJoin(realRowIndex, rowCount)) {
if (rowHeight === 0 && i !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) {
output += (0, _drawBorder.drawBorderJoin)(columnSizeIndex, border);

@@ -58,3 +61,5 @@ }

output += (0, _drawBorder.drawBorderBottom)(columnSizeIndex, border);
if (drawHorizontalLine(realRowIndex, rowCount)) {
output += (0, _drawBorder.drawBorderBottom)(columnSizeIndex, border);
}

@@ -61,0 +66,0 @@ return output;

@@ -95,7 +95,7 @@ 'use strict';

if (!config.drawJoin) {
if (!config.drawHorizontalLine) {
/**
* @returns {boolean}
*/
config.drawJoin = function () {
config.drawHorizontalLine = function () {
return true;

@@ -102,0 +102,0 @@ };

@@ -13,3 +13,3 @@ {

},
"drawJoin": {
"drawHorizontalLine": {
"type": "function"

@@ -16,0 +16,0 @@ }

@@ -94,6 +94,7 @@ 'use strict';

/**
* Used to dynamically tell table whether to draw a line separating rows or not.
* Used to tell whether to draw a horizontal line.
* This callback is called for each non-content line of the table.
* The default behavior is to always return true.
*
* @typedef {function} drawJoin
* @typedef {function} drawHorizontalLine
* @param {number} index

@@ -109,3 +110,3 @@ * @param {number} size

* @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values.
* @property {table~drawJoin} drawJoin
* @property {table~drawHorizontalLine} drawHorizontalLine
*/

@@ -145,3 +146,3 @@

return (0, _drawTable2['default'])(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawJoin);
return (0, _drawTable2['default'])(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine);
};

@@ -148,0 +149,0 @@

{
"name": "table",
"version": "3.4.0",
"version": "3.5.0",
"description": "Formats data into a string table.",

@@ -46,2 +46,3 @@ "main": "./dist/index.js",

"dependencies": {
"ansi": "^0.3.0",
"ansi-slice": "^1.2.0",

@@ -48,0 +49,0 @@ "bluebird": "^2.10.2",

@@ -13,3 +13,3 @@ <h1 id="table">Table</h1>

* [Custom Border](#table-usage-custom-border)
* [Draw Join](#table-usage-draw-join)
* [Draw Horizontal Line](#table-usage-draw-horizontal-line)
* [Padding Cell Content](#table-usage-padding-cell-content)

@@ -102,3 +102,3 @@ * [Predefined Border Templates](#table-usage-predefined-border-templates)

* @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values.
* @property {table~drawJoin} drawJoin
* @property {table~drawJoin} drawHorizontalLine
*/

@@ -269,5 +269,5 @@

<h3 id="table-usage-draw-join">Draw Join</h3>
<h3 id="table-usage-draw-horizontal-line">Draw Horizontal Line</h3>
`{function} config.drawJoin` property is a function that is called for every row in the table. The result of the function `{boolean}` determines whether a join/separating row is drawn.
`{function} config.drawHorizontalLine` property is a function that is called for every non-content row in the table. The result of the function `{boolean}` determines whether a row is drawn.

@@ -289,5 +289,2 @@ ```js

/**
* Used to dynamically tell table whether to draw a line separating rows or not.
* The default behavior is to always return true.
*
* @typedef {function} drawJoin

@@ -298,8 +295,4 @@ * @param {number} index

*/
drawJoin: (index, size) => {
// This implementation draws a separating line only after the first row
// and before the last row.
if (index === 1 || index === size - 1) {
return true;
}
drawHorizontalLine: (index, size) => {
return index === 0 || index === 1 || index === size - 1 || index === size;
}

@@ -306,0 +299,0 @@ };

@@ -13,5 +13,5 @@ import _ from 'lodash';

* @param {Array} rowSpanIndex
* @param {function} drawJoin
* @param {function} drawHorizontalLine
*/
export default (rows, border, columnSizeIndex, rowSpanIndex, drawJoin) => {
export default (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => {
let output,

@@ -27,4 +27,7 @@ rowCount,

output = '';
output += drawBorderTop(columnSizeIndex, border);
if (drawHorizontalLine(realRowIndex, rowCount)) {
output += drawBorderTop(columnSizeIndex, border);
}
_.forEach(rows, (row, i) => {

@@ -41,3 +44,3 @@ output += drawRow(row, border);

if (rowHeight === 0 && i !== rowCount - 1 && drawJoin(realRowIndex, rowCount)) {
if (rowHeight === 0 && i !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) {
output += drawBorderJoin(columnSizeIndex, border);

@@ -47,5 +50,7 @@ }

output += drawBorderBottom(columnSizeIndex, border);
if (drawHorizontalLine(realRowIndex, rowCount)) {
output += drawBorderBottom(columnSizeIndex, border);
}
return output;
};

@@ -68,7 +68,7 @@ import _ from 'lodash';

if (!config.drawJoin) {
if (!config.drawHorizontalLine) {
/**
* @returns {boolean}
*/
config.drawJoin = () => {
config.drawHorizontalLine = () => {
return true;

@@ -75,0 +75,0 @@ };

@@ -13,3 +13,3 @@ {

},
"drawJoin": {
"drawHorizontalLine": {
"type": "function"

@@ -16,0 +16,0 @@ }

@@ -51,6 +51,7 @@ import _ from 'lodash';

/**
* Used to dynamically tell table whether to draw a line separating rows or not.
* Used to tell whether to draw a horizontal line.
* This callback is called for each non-content line of the table.
* The default behavior is to always return true.
*
* @typedef {function} drawJoin
* @typedef {function} drawHorizontalLine
* @param {number} index

@@ -66,3 +67,3 @@ * @param {number} size

* @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values.
* @property {table~drawJoin} drawJoin
* @property {table~drawHorizontalLine} drawHorizontalLine
*/

@@ -99,3 +100,3 @@

return drawTable(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawJoin);
return drawTable(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine);
};

@@ -108,3 +108,3 @@ import {

},
drawJoin: () => {
drawHorizontalLine: () => {
return false

@@ -111,0 +111,0 @@ }

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