getFilter
Description
The function retrieves a filter configuration object based on the provided filter id and typeUsage
getFilter(
id: string,
type?: "text" | "number" | "date" | "tuple"
): {
id:string,
label:string,
short?:string,
default?:boolean,
type:"text" | "number" | "date" | "tuple",
handler: (a: any, b:any) => boolean
} | undefined;
Parameters
id
- (required) the id of the filter to retrievetype
- (optional) the type of the filter. If not provided, the function defaults to "text".
Returns
Returns the filter object that matches the provided id
and optionally the type
. If no matches are found, returns undefined
. Filter object contains:
id
- (required) - filter operator id, e.g. "notEqual"label
- (required) - text label, e.g. "not equal"short
- (optional) - short text label, e.g. "!="default
- (optional) - defined whether this filter is default for its data typetype
- (required) filter type ("text", "number", "tuple", "date")handler
- (required) comparison function
Example
The example shows how to output the filter object to the console:
import { getFilter } from "wx-svelte-filter";
// logs numeric "equal" filter
console.log(getFilter("equal", "number"));