MCPcopy Create free account
hub / github.com/plotly/dash / getter

Function getter

components/dash-table/src/dash-table/derived/data/virtual.ts:17–53  ·  view source on GitHub ↗
(
    columns: Columns,
    data: Data,
    filter_action: IFilterAction,
    filter_query: string,
    sort_action: TableAction,
    sort_by: SortBy = []
)

Source from the content-addressed store, hash-verified

15import {QuerySyntaxTree} from 'dash-table/syntax-tree';
16
17const getter = (
18 columns: Columns,
19 data: Data,
20 filter_action: IFilterAction,
21 filter_query: string,
22 sort_action: TableAction,
23 sort_by: SortBy = []
24): IDerivedData => {
25 const map = new Map<Datum, number>();
26 R.addIndex<Datum>(R.forEach)((datum, index) => {
27 map.set(datum, index);
28 }, data);
29
30 if (filter_action.type === TableAction.Native) {
31 const tree = new QuerySyntaxTree(filter_query);
32
33 data = tree.isValid ? tree.filter(data) : data;
34 }
35
36 const getNullyCases = (columnId: ColumnId): SortAsNull => {
37 const column = R.find(c => c.id === columnId, columns);
38
39 return (column && column.sort_as_null) || [];
40 };
41
42 const isNully = (value: any, columnId: ColumnId): any =>
43 R.isNil(value) || R.includes(value, getNullyCases(columnId));
44
45 if (sort_action === TableAction.Native) {
46 data = sort(data, sort_by, isNully);
47 }
48
49 // virtual_indices
50 const indices = R.map(datum => map.get(datum) as number, data);
51
52 return {data, indices};
53};
54
55export default memoizeOneFactory(getter);

Callers

nothing calls this directly

Calls 3

filterMethod · 0.80
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…