Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
44 lines
1.6 KiB
Plaintext
44 lines
1.6 KiB
Plaintext
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.preProcessRows = exports.preProcessColumns = void 0;
|
|
const table_helpers_1 = require("../utils/table-helpers");
|
|
const createComputedColumnsIfNecessary = (table) => {
|
|
if (table.computedColumns.length) {
|
|
table.computedColumns.forEach((computedColumn) => {
|
|
table.addColumn(computedColumn);
|
|
table.rows.forEach((row) => {
|
|
row.text[computedColumn.name] = computedColumn.function(row.text);
|
|
});
|
|
});
|
|
}
|
|
};
|
|
const disableColumnsIfNecessary = (table) => {
|
|
if (table.enabledColumns.length) {
|
|
table.columns = table.columns.filter((col) => table.enabledColumns.includes(col.name));
|
|
}
|
|
};
|
|
const enableColumnsIfNecessary = (table) => {
|
|
if (table.disabledColumns.length) {
|
|
table.columns = table.columns.filter((col) => !table.disabledColumns.includes(col.name));
|
|
}
|
|
};
|
|
const findColumnWidth = (table) => {
|
|
table.columns.forEach((column) => {
|
|
column.length = (0, table_helpers_1.findLenOfColumn)(column, table.rows, table.charLength);
|
|
});
|
|
};
|
|
const preProcessColumns = (table) => {
|
|
createComputedColumnsIfNecessary(table);
|
|
enableColumnsIfNecessary(table);
|
|
disableColumnsIfNecessary(table);
|
|
findColumnWidth(table);
|
|
};
|
|
exports.preProcessColumns = preProcessColumns;
|
|
const preProcessRows = (table) => {
|
|
const newRows = table.rows
|
|
.filter((r) => table.filterFunction(r.text))
|
|
.sort((r1, r2) => table.sortFunction(r1.text, r2.text));
|
|
table.rows = newRows;
|
|
};
|
|
exports.preProcessRows = preProcessRows;
|