dtable-utils
Version:
dtable common utils
28 lines (25 loc) • 787 B
JavaScript
/**
* Get column by key from table
* @param {object} table
* @param {string} columnKey
* @returns column, object
*/
var getTableColumnByKey = function getTableColumnByKey(table, columnKey) {
if (!table || !Array.isArray(table.columns) || !columnKey) return null;
return table.columns.find(function (column) {
return column.key === columnKey;
});
};
/**
* Get table column by name
* @param {object} table
* @param {string} columnName
* @returns column, object
*/
var getTableColumnByName = function getTableColumnByName(table, columnName) {
if (!table || !Array.isArray(table.columns) || !columnName) return null;
return table.columns.find(function (column) {
return column.name === columnName;
});
};
export { getTableColumnByKey, getTableColumnByName };