MCPcopy Create free account
hub / github.com/microsoft/SandDance / runExpressionOnColumn

Method runExpressionOnColumn

docs/tests/v2/es6/js/sanddance.js:153079–153135  ·  view source on GitHub ↗
(datum, ex)

Source from the content-addressed store, hash-verified

153077 }
153078
153079 runExpressionOnColumn(datum, ex) {
153080 const actualDataValue = datum[ex.name];
153081
153082 if (ex.operator === 'isnullorEmpty') {
153083 return isnullorEmpty(actualDataValue);
153084 } else if (ex.operator === '!isnullorEmpty') {
153085 return !isnullorEmpty(actualDataValue);
153086 }
153087
153088 let dataValue = actualDataValue;
153089 let expressionValue = ex.value;
153090
153091 if (ex.column) {
153092 if (ex.column.type === 'string' || ex.stringOperation) {
153093 dataValue = valueToString(actualDataValue).toLocaleLowerCase();
153094 expressionValue = ex.valueLow;
153095 } else if (ex.column.type === 'boolean') {
153096 dataValue = valueToBoolean(actualDataValue);
153097 expressionValue = ex.valueBool;
153098 } else if (ex.column.quantitative) {
153099 dataValue = +actualDataValue;
153100 expressionValue = +ex.value;
153101 }
153102 }
153103
153104 switch (ex.operator) {
153105 case '!=':
153106 return dataValue != expressionValue;
153107
153108 case '<':
153109 return dataValue < expressionValue;
153110
153111 case '<=':
153112 return dataValue <= expressionValue;
153113
153114 case '==':
153115 return dataValue == expressionValue;
153116
153117 case '>':
153118 return dataValue > expressionValue;
153119
153120 case '>=':
153121 return dataValue >= expressionValue;
153122
153123 case 'contains':
153124 return dataValue.indexOf(expressionValue) >= 0;
153125
153126 case '!contains':
153127 return dataValue.indexOf(expressionValue) < 0;
153128
153129 case 'starts':
153130 return dataValue.indexOf(expressionValue) == 0;
153131
153132 case '!starts':
153133 return dataValue.indexOf(expressionValue) !== 0;
153134 }
153135 }
153136

Callers 1

runExpressionMethod · 0.95

Calls 3

isnullorEmptyFunction · 0.70
valueToStringFunction · 0.70
valueToBooleanFunction · 0.70

Tested by

no test coverage detected