filterClause.ts
TLDR
This file, filterClause.ts
, provides functionality related to creating and comparing filter clauses. It exports the FilterClause
type, the FilterCondition
type, and three functions: createFilterClause
, and areEqual
.
Methods
createFilterClause
This method creates a new FilterClause
object based on the provided parameters. If no parameters are provided, the method returns a FilterClause
object with default values: an empty string for propertyId
, 'includes' for condition
, and an empty array for values
.
areEqual
This method compares two FilterClause
objects and returns a boolean value indicating whether they are equal. The comparison is based on the equality of the propertyId
, condition
, and values
properties.
Classes
There are no classes in this file.
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Utils} from '../utils'
type FilterCondition =
'includes' | 'notIncludes' |
'isEmpty' | 'isNotEmpty' |
'isSet' | 'isNotSet' |
'is' |
'contains' | 'notContains' |
'startsWith' | 'notStartsWith' |
'endsWith' | 'notEndsWith' |
'isBefore' | 'isAfter'
type FilterClause = {
propertyId: string
condition: FilterCondition
values: string[]
}
function createFilterClause(o?: FilterClause): FilterClause {
return {
propertyId: o?.propertyId || '',
condition: o?.condition || 'includes',
values: o?.values?.slice() || [],
}
}
function areEqual(a: FilterClause, b: FilterClause): boolean {
return (
a.propertyId === b.propertyId &&
a.condition === b.condition &&
Utils.arraysEqual(a.values, b.values)
)
}
export {FilterClause, FilterCondition, createFilterClause, areEqual}