table 6.5.1 → 6.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -25
- package/dist/alignString.d.ts +2 -3
- package/dist/alignString.js +21 -4
- package/dist/alignTableData.d.ts +1 -2
- package/dist/alignTableData.js +7 -5
- package/dist/calculateCellHeight.d.ts +4 -2
- package/dist/calculateCellHeight.js +8 -9
- package/dist/calculateCellWidths.d.ts +5 -0
- package/dist/{calculateCellWidthIndex.js → calculateCellWidths.js} +6 -6
- package/dist/{calculateMaximumColumnWidthIndex.d.ts → calculateColumnWidths.d.ts} +0 -0
- package/dist/calculateColumnWidths.js +16 -0
- package/dist/calculateRowHeights.d.ts +5 -0
- package/dist/calculateRowHeights.js +18 -0
- package/dist/createStream.d.ts +1 -2
- package/dist/createStream.js +29 -30
- package/dist/drawBorder.d.ts +4 -4
- package/dist/drawBorder.js +16 -13
- package/dist/drawContent.d.ts +11 -0
- package/dist/drawContent.js +26 -0
- package/dist/drawRow.d.ts +1 -2
- package/dist/drawRow.js +11 -13
- package/dist/drawTable.d.ts +1 -2
- package/dist/drawTable.js +20 -40
- package/dist/generated/validators.d.ts +2 -2
- package/dist/generated/validators.js +282 -274
- package/dist/getBorderCharacters.d.ts +1 -2
- package/dist/getBorderCharacters.js +3 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -9
- package/dist/makeConfig.d.ts +1 -2
- package/dist/makeConfig.js +12 -19
- package/dist/makeStreamConfig.d.ts +1 -2
- package/dist/makeStreamConfig.js +8 -19
- package/dist/mapDataUsingRowHeights.d.ts +2 -0
- package/dist/mapDataUsingRowHeights.js +29 -0
- package/dist/padTableData.d.ts +1 -2
- package/dist/padTableData.js +6 -4
- package/dist/stringifyTableData.d.ts +1 -2
- package/dist/stringifyTableData.js +7 -2
- package/dist/table.d.ts +1 -2
- package/dist/table.js +23 -24
- package/dist/truncateTableData.d.ts +1 -2
- package/dist/truncateTableData.js +6 -4
- package/dist/types/api.d.ts +2 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +93 -0
- package/dist/validateConfig.d.ts +1 -2
- package/dist/validateConfig.js +3 -1
- package/dist/validateTableData.d.ts +1 -2
- package/dist/validateTableData.js +5 -2
- package/dist/wrapCell.d.ts +1 -2
- package/dist/wrapCell.js +9 -24
- package/dist/wrapString.d.ts +1 -2
- package/dist/wrapString.js +3 -1
- package/dist/wrapWord.d.ts +1 -2
- package/dist/wrapWord.js +3 -1
- package/package.json +1 -1
- package/dist/calculateCellWidthIndex.d.ts +0 -6
- package/dist/calculateMaximumColumnWidthIndex.js +0 -24
- package/dist/calculateRowHeightIndex.d.ts +0 -6
- package/dist/calculateRowHeightIndex.js +0 -21
- package/dist/drawHorizontalContent.d.ts +0 -11
- package/dist/drawHorizontalContent.js +0 -18
- package/dist/mapDataUsingRowHeightIndex.d.ts +0 -3
- package/dist/mapDataUsingRowHeightIndex.js +0 -26
package/dist/wrapWord.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.wrapWord = void 0;
|
|
6
7
|
const slice_ansi_1 = __importDefault(require("slice-ansi"));
|
|
7
8
|
const strip_ansi_1 = __importDefault(require("strip-ansi"));
|
|
8
9
|
const calculateStringLengths = (input, size) => {
|
|
@@ -28,7 +29,7 @@ const calculateStringLengths = (input, size) => {
|
|
|
28
29
|
} while (subject.length);
|
|
29
30
|
return chunks;
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
+
const wrapWord = (input, size) => {
|
|
32
33
|
const result = [];
|
|
33
34
|
let startIndex = 0;
|
|
34
35
|
calculateStringLengths(input, size).forEach(([length, offset]) => {
|
|
@@ -37,3 +38,4 @@ exports.default = (input, size) => {
|
|
|
37
38
|
});
|
|
38
39
|
return result;
|
|
39
40
|
};
|
|
41
|
+
exports.wrapWord = wrapWord;
|
package/package.json
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const calculateCellWidthIndex_1 = __importDefault(require("./calculateCellWidthIndex"));
|
|
7
|
-
/**
|
|
8
|
-
* Produces an array of values that describe the largest value length (width) in every column.
|
|
9
|
-
*/
|
|
10
|
-
exports.default = (rows) => {
|
|
11
|
-
if (!rows[0]) {
|
|
12
|
-
throw new Error('Dataset must have at least one row.');
|
|
13
|
-
}
|
|
14
|
-
const columns = new Array(rows[0].length).fill(0);
|
|
15
|
-
rows.forEach((row) => {
|
|
16
|
-
const columnWidthIndex = calculateCellWidthIndex_1.default(row);
|
|
17
|
-
columnWidthIndex.forEach((valueWidth, index0) => {
|
|
18
|
-
if (columns[index0] < valueWidth) {
|
|
19
|
-
columns[index0] = valueWidth;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
return columns;
|
|
24
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const calculateCellHeight_1 = __importDefault(require("./calculateCellHeight"));
|
|
7
|
-
/**
|
|
8
|
-
* Calculates the vertical row span index.
|
|
9
|
-
*/
|
|
10
|
-
exports.default = (rows, config) => {
|
|
11
|
-
const tableWidth = rows[0].length;
|
|
12
|
-
const rowSpanIndex = [];
|
|
13
|
-
rows.forEach((cells) => {
|
|
14
|
-
const cellHeightIndex = new Array(tableWidth).fill(1);
|
|
15
|
-
cells.forEach((value, index1) => {
|
|
16
|
-
cellHeightIndex[index1] = calculateCellHeight_1.default(value, config.columns[index1].width, config.columns[index1].wrapWord);
|
|
17
|
-
});
|
|
18
|
-
rowSpanIndex.push(Math.max(...cellHeightIndex));
|
|
19
|
-
});
|
|
20
|
-
return rowSpanIndex;
|
|
21
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { DrawVerticalLine } from './types/api';
|
|
2
|
-
declare type Separator = {
|
|
3
|
-
readonly left: string;
|
|
4
|
-
readonly right: string;
|
|
5
|
-
readonly join: string;
|
|
6
|
-
};
|
|
7
|
-
export default function drawHorizontalContent(contents: string[], config: {
|
|
8
|
-
separator: Separator;
|
|
9
|
-
drawVerticalLine: DrawVerticalLine;
|
|
10
|
-
}): string;
|
|
11
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function drawHorizontalContent(contents, config) {
|
|
4
|
-
const { separator, drawVerticalLine } = config;
|
|
5
|
-
const contentSize = contents.length;
|
|
6
|
-
const result = [];
|
|
7
|
-
result.push(drawVerticalLine(0, contentSize) ? separator.left : '');
|
|
8
|
-
contents.forEach((content, index) => {
|
|
9
|
-
result.push(content);
|
|
10
|
-
// Only append the join separator if it is not the last content
|
|
11
|
-
if (index + 1 < contentSize) {
|
|
12
|
-
result.push(drawVerticalLine(index + 1, contentSize) ? separator.join : '');
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
result.push(drawVerticalLine(contentSize, contentSize) ? separator.right : '');
|
|
16
|
-
return result.join('') + '\n';
|
|
17
|
-
}
|
|
18
|
-
exports.default = drawHorizontalContent;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const lodash_flatten_1 = __importDefault(require("lodash.flatten"));
|
|
7
|
-
const wrapCell_1 = __importDefault(require("./wrapCell"));
|
|
8
|
-
exports.default = (unmappedRows, rowHeightIndex, config) => {
|
|
9
|
-
const tableWidth = unmappedRows[0].length;
|
|
10
|
-
const mappedRows = unmappedRows.map((row, index0) => {
|
|
11
|
-
const rowHeight = Array.from({ length: rowHeightIndex[index0] }, () => {
|
|
12
|
-
return new Array(tableWidth).fill('');
|
|
13
|
-
});
|
|
14
|
-
// rowHeight
|
|
15
|
-
// [{row index within rowSaw; index2}]
|
|
16
|
-
// [{cell index within a virtual row; index1}]
|
|
17
|
-
row.forEach((cell, index1) => {
|
|
18
|
-
const cellLines = wrapCell_1.default(cell, config.columns[index1].width, config.columns[index1].wrapWord);
|
|
19
|
-
cellLines.forEach((cellLine, index2) => {
|
|
20
|
-
rowHeight[index2][index1] = cellLine;
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
return rowHeight;
|
|
24
|
-
});
|
|
25
|
-
return lodash_flatten_1.default(mappedRows);
|
|
26
|
-
};
|