dtable-utils
Version:
dtable common utils
42 lines (39 loc) • 961 B
JavaScript
import _typeof from '@babel/runtime/helpers/typeof';
import { FILTER_PREDICATE_TYPE } from '../../constants/filter/filter-predicate.js';
import { isEmptyObject } from '../../common.js';
/**
* Filter long-text
* @param {any} value
* @param {string} filter_predicate
* @returns bool
*/
var longTextFilter = function longTextFilter(value, _ref) {
var filter_predicate = _ref.filter_predicate;
var text;
if (typeof value === 'string') {
text = value.trim();
} else if (_typeof(value) === 'object') {
if (isEmptyObject(value)) {
text = null;
} else {
text = typeof value.text === 'string' ? value.text.trim() : null;
}
} else {
text = null;
}
switch (filter_predicate) {
case FILTER_PREDICATE_TYPE.EMPTY:
{
return !text;
}
case FILTER_PREDICATE_TYPE.NOT_EMPTY:
{
return !!text;
}
default:
{
return false;
}
}
};
export { longTextFilter };