table
Advanced tools
Comparing version 5.3.3 to 5.4.0
@@ -20,5 +20,6 @@ "use strict"; | ||
* @param {Function} drawHorizontalLine | ||
* @param {boolean} singleLine | ||
* @returns {string} | ||
*/ | ||
const drawTable = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => { | ||
const drawTable = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine, singleLine) => { | ||
let output; | ||
@@ -45,3 +46,3 @@ let realRowIndex; | ||
if (rowHeight === 0 && index0 !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) { | ||
if (!singleLine && rowHeight === 0 && index0 !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) { | ||
output += (0, _drawBorder.drawBorderJoin)(columnSizeIndex, border); | ||
@@ -48,0 +49,0 @@ } |
@@ -85,2 +85,6 @@ "use strict"; | ||
if (config.singleLine === undefined) { | ||
config.singleLine = false; | ||
} | ||
return config; | ||
@@ -87,0 +91,0 @@ }; |
@@ -84,2 +84,3 @@ "use strict"; | ||
* @property {table~drawHorizontalLine} drawHorizontalLine | ||
* @property {table~singleLine} singleLine Horizontal lines inside the table are not drawn. | ||
*/ | ||
@@ -105,3 +106,3 @@ | ||
const cellWidthIndex = (0, _calculateCellWidthIndex.default)(rows[0]); | ||
return (0, _drawTable.default)(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine); | ||
return (0, _drawTable.default)(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine, config.singleLine); | ||
}; | ||
@@ -108,0 +109,0 @@ |
@@ -82,3 +82,3 @@ { | ||
}, | ||
"version": "5.3.3" | ||
"version": "5.4.0" | ||
} |
@@ -19,2 +19,3 @@ <a name="table"></a> | ||
* [Draw Horizontal Line](#table-usage-draw-horizontal-line) | ||
* [Single Line Mode](#table-usage-single-line-mode) | ||
* [Padding Cell Content](#table-usage-padding-cell-content) | ||
@@ -345,2 +346,45 @@ * [Predefined Border Templates](#table-usage-predefined-border-templates) | ||
<a name="table-usage-single-line-mode"></a> | ||
### Single Line Mode | ||
Horizontal lines inside the table are not drawn. | ||
```js | ||
import { | ||
table, | ||
getBorderCharacters | ||
} from 'table'; | ||
const data = [ | ||
['-rw-r--r--', '1', 'pandorym', 'staff', '1529', 'May 23 11:25', 'LICENSE'], | ||
['-rw-r--r--', '1', 'pandorym', 'staff', '16327', 'May 23 11:58', 'README.md'], | ||
['drwxr-xr-x', '76', 'pandorym', 'staff', '2432', 'May 23 12:02', 'dist'], | ||
['drwxr-xr-x', '634', 'pandorym', 'staff', '20288', 'May 23 11:54', 'node_modules'], | ||
['-rw-r--r--', '1,', 'pandorym', 'staff', '525688', 'May 23 11:52', 'package-lock.json'], | ||
['-rw-r--r--@', '1', 'pandorym', 'staff', '2440', 'May 23 11:25', 'package.json'], | ||
['drwxr-xr-x', '27', 'pandorym', 'staff', '864', 'May 23 11:25', 'src'], | ||
['drwxr-xr-x', '20', 'pandorym', 'staff', '640', 'May 23 11:25', 'test'], | ||
]; | ||
const config = { | ||
singleLine: true | ||
}; | ||
const output = table(data, config); | ||
console.log(output); | ||
``` | ||
``` | ||
╔═════════════╤═════╤══════════╤═══════╤════════╤══════════════╤═══════════════════╗ | ||
║ -rw-r--r-- │ 1 │ pandorym │ staff │ 1529 │ May 23 11:25 │ LICENSE ║ | ||
║ -rw-r--r-- │ 1 │ pandorym │ staff │ 16327 │ May 23 11:58 │ README.md ║ | ||
║ drwxr-xr-x │ 76 │ pandorym │ staff │ 2432 │ May 23 12:02 │ dist ║ | ||
║ drwxr-xr-x │ 634 │ pandorym │ staff │ 20288 │ May 23 11:54 │ node_modules ║ | ||
║ -rw-r--r-- │ 1, │ pandorym │ staff │ 525688 │ May 23 11:52 │ package-lock.json ║ | ||
║ -rw-r--r--@ │ 1 │ pandorym │ staff │ 2440 │ May 23 11:25 │ package.json ║ | ||
║ drwxr-xr-x │ 27 │ pandorym │ staff │ 864 │ May 23 11:25 │ src ║ | ||
║ drwxr-xr-x │ 20 │ pandorym │ staff │ 640 │ May 23 11:25 │ test ║ | ||
╚═════════════╧═════╧══════════╧═══════╧════════╧══════════════╧═══════════════════╝ | ||
``` | ||
<a name="table-usage-padding-cell-content"></a> | ||
@@ -347,0 +391,0 @@ ### Padding Cell Content |
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
196772
2848
736