UNPKG

smart-table-filter

Version:

takes a configuration object and returns a filter function operating on arrays

31 lines (30 loc) 830 B
declare enum Type { BOOLEAN = "boolean", NUMBER = "number", DATE = "date", STRING = "string" } declare type TypeOrAny = Type | any; export declare const enum FilterOperator { INCLUDES = "includes", IS = "is", IS_NOT = "isNot", LOWER_THAN = "lt", GREATER_THAN = "gt", GREATER_THAN_OR_EQUAL = "gte", LOWER_THAN_OR_EQUAL = "lte", EQUALS = "equals", NOT_EQUALS = "notEquals", ANY_OF = "anyOf" } export interface PredicateDefinition { type?: TypeOrAny; operator?: FilterOperator; value?: any; } export declare const predicate: ({ value, operator, type }: PredicateDefinition) => Function; export interface FilterConfiguration { [s: string]: PredicateDefinition[]; } export declare const filter: <T>(filter: FilterConfiguration) => (array: T[]) => T[]; export {};