mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-20 09:04:08 +00:00
17 lines
504 B
TypeScript
17 lines
504 B
TypeScript
|
import { CellValue } from "app/common/DocActions";
|
||
|
import { ColumnFilterFunc } from "app/common/ColumnFilterFunc";
|
||
|
|
||
|
export type RowFilterFunc<T> = (row: T) => boolean;
|
||
|
|
||
|
// Builds RowFilter for a single column
|
||
|
export function buildRowFilter<T>(
|
||
|
getter: RowValueFunc<T> | null,
|
||
|
filterFunc: ColumnFilterFunc | null): RowFilterFunc<T> {
|
||
|
if (!getter || !filterFunc) {
|
||
|
return () => true;
|
||
|
}
|
||
|
return (rowId: T) => filterFunc(getter(rowId));
|
||
|
}
|
||
|
|
||
|
export type RowValueFunc<T> = (rowId: T) => CellValue;
|