MCPcopy Index your code
hub / github.com/microsoft/SandDance / runExpressionOnColumn

Method runExpressionOnColumn

packages/search-expression/src/exec.ts:82–125  ·  view source on GitHub ↗
(datum: object, ex: SearchExpressionLowercase)

Source from the content-addressed store, hash-verified

80 }
81
82 private runExpressionOnColumn(datum: object, ex: SearchExpressionLowercase) {
83 const actualDataValue = datum[ex.name];
84 if (ex.operator === 'isnullorEmpty') {
85 return isnullorEmpty(actualDataValue);
86 } else if (ex.operator === '!isnullorEmpty') {
87 return !isnullorEmpty(actualDataValue);
88 }
89 let dataValue = actualDataValue;
90 let expressionValue = ex.value;
91 if (ex.column) {
92 if (ex.column.type === 'string' || ex.stringOperation) {
93 dataValue = valueToString(actualDataValue).toLocaleLowerCase();
94 expressionValue = ex.valueLow;
95 } else if (ex.column.type === 'boolean') {
96 dataValue = valueToBoolean(actualDataValue);
97 expressionValue = ex.valueBool;
98 } else if (ex.column.quantitative) {
99 dataValue = +actualDataValue;
100 expressionValue = +ex.value;
101 }
102 }
103 switch (ex.operator) {
104 case '!=':
105 return dataValue != expressionValue;
106 case '<':
107 return dataValue < expressionValue;
108 case '<=':
109 return dataValue <= expressionValue;
110 case '==':
111 return dataValue == expressionValue;
112 case '>':
113 return dataValue > expressionValue;
114 case '>=':
115 return dataValue >= expressionValue;
116 case 'contains':
117 return dataValue.indexOf(expressionValue) >= 0;
118 case '!contains':
119 return dataValue.indexOf(expressionValue) < 0;
120 case 'starts':
121 return dataValue.indexOf(expressionValue) == 0;
122 case '!starts':
123 return dataValue.indexOf(expressionValue) !== 0;
124 }
125 }
126
127 private runExpression(datum: object, ex: SearchExpressionLowercase) {
128 if (ex.name == null) {

Callers 1

runExpressionMethod · 0.95

Calls 3

isnullorEmptyFunction · 0.70
valueToStringFunction · 0.70
valueToBooleanFunction · 0.70

Tested by

no test coverage detected