dtable-utils
Version:
dtable common utils
50 lines (44 loc) • 1.25 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var cellType = require('../constants/cell-type.js');
var formula = require('../constants/formula.js');
/**
* Get column type.
* @param {object} column { type, ... }
* @returns column type
*/
var getColumnType = function getColumnType(column) {
var type = column.type,
data = column.data;
if (formula.FORMULA_COLUMN_TYPES_MAP[type]) {
var _ref = data || {},
result_type = _ref.result_type,
array_type = _ref.array_type;
if (result_type === formula.FORMULA_RESULT_TYPE.ARRAY) {
return array_type;
}
return result_type;
}
if (type === cellType.CellType.LINK) {
var _ref2 = data || {},
_array_type = _ref2.array_type;
return _array_type;
}
return type;
};
/**
* Get columns by type.
* @param {array} columns
* @param {string} columnType
* @returns the target type columns, array
*/
var getColumnsByType = function getColumnsByType(columns, columnType) {
if (!Array.isArray(columns) || !columnType) {
return [];
}
return columns.filter(function (column) {
return column.type === columnType;
});
};
exports.getColumnType = getColumnType;
exports.getColumnsByType = getColumnsByType;