MCPcopy Index your code
hub / github.com/apache/echarts / evaluate

Method evaluate

src/data/helper/dataValueHelper.ts:162–189  ·  view source on GitHub ↗
(lval: unknown, rval: unknown)

Source from the content-addressed store, hash-verified

160 // See [SORT_COMPARISON_RULE].
161 // Performance sensitive.
162 evaluate(lval: unknown, rval: unknown): -1 | 0 | 1 {
163 // Most cases is 'number', and typeof maybe 10 times faseter than parseFloat.
164 let lvalFloat = isNumber(lval) ? lval : numericToNumber(lval);
165 let rvalFloat = isNumber(rval) ? rval : numericToNumber(rval);
166 const lvalNotNumeric = isNaN(lvalFloat as number);
167 const rvalNotNumeric = isNaN(rvalFloat as number);
168
169 if (lvalNotNumeric) {
170 lvalFloat = this._incomparable;
171 }
172 if (rvalNotNumeric) {
173 rvalFloat = this._incomparable;
174 }
175 if (lvalNotNumeric && rvalNotNumeric) {
176 const lvalIsStr = isString(lval);
177 const rvalIsStr = isString(rval);
178 if (lvalIsStr) {
179 lvalFloat = rvalIsStr ? lval as unknown as number : 0;
180 }
181 if (rvalIsStr) {
182 rvalFloat = lvalIsStr ? rval as unknown as number : 0;
183 }
184 }
185
186 return lvalFloat < rvalFloat ? this._resultLT
187 : lvalFloat > rvalFloat ? (-this._resultLT as -1 | 1)
188 : 0;
189 }
190}
191
192class FilterEqualityComparator implements FilterComparator {

Callers 2

testSortComparatorFunction · 0.95
buildSectionFunction · 0.95

Calls 2

numericToNumberFunction · 0.90
isNumberFunction · 0.85

Tested by 1

testSortComparatorFunction · 0.76