MCPcopy
hub / github.com/plotly/dash / getSingleColumnMap

Function getSingleColumnMap

components/dash-table/src/dash-table/syntax-tree/index.ts:25–96  ·  view source on GitHub ↗
(
    ast: MultiColumnsSyntaxTree,
    columns: IColumn[]
)

Source from the content-addressed store, hash-verified

23 ).join(` ${operator === FilterLogicalOperator.And ? '&&' : '||'} `);
24
25export const getSingleColumnMap = (
26 ast: MultiColumnsSyntaxTree,
27 columns: IColumn[]
28) => {
29 if (!ast.isValid) {
30 return;
31 }
32
33 const map = new Map<string, SingleColumnSyntaxTree>();
34
35 const statements = ast.statements;
36 if (!statements) {
37 return map;
38 }
39
40 statements.forEach(s => {
41 if (s.lexeme.type === LexemeType.UnaryOperator && s.left) {
42 const sanitizedColumnId = s.left.lexeme.present
43 ? s.left.lexeme.present(s.left)
44 : s.left.value;
45
46 const column = R.find(
47 c => c.id.toString() === sanitizedColumnId,
48 columns
49 );
50 if (!column) {
51 throw new Error(`column ${sanitizedColumnId} not found`);
52 }
53
54 map.set(
55 sanitizedColumnId,
56 new SingleColumnSyntaxTree(s.value, column)
57 );
58 } else if (
59 s.lexeme.type === LexemeType.RelationalOperator &&
60 s.left &&
61 s.right
62 ) {
63 const sanitizedColumnId = s.left.lexeme.present
64 ? s.left.lexeme.present(s.left)
65 : s.left.value;
66
67 const column = R.find(
68 c => c.id.toString() === sanitizedColumnId,
69 columns
70 );
71 if (!column) {
72 throw new Error(`column ${sanitizedColumnId} not found`);
73 }
74
75 if (
76 s.lexeme.present &&
77 s.lexeme.present(s) === RelationalOperator.Equal
78 ) {
79 map.set(
80 sanitizedColumnId,
81 new SingleColumnSyntaxTree(`${s.right.value}`, column)
82 );

Callers 1

map.tsFile · 0.90

Calls 3

findMethod · 0.80
toStringMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…