MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / createPredicateFn

Function createPredicateFn

lib/test/angular/1.6.7/angular.js:21141–21176  ·  view source on GitHub ↗
(expression, comparator, anyPropertyKey, matchAgainstAnyProp)

Source from the content-addressed store, hash-verified

21139
21140// Helper functions for `filterFilter`
21141function createPredicateFn(expression, comparator, anyPropertyKey, matchAgainstAnyProp) {
21142 var shouldMatchPrimitives = isObject(expression) && (anyPropertyKey in expression);
21143 var predicateFn;
21144
21145 if (comparator === true) {
21146 comparator = equals;
21147 } else if (!isFunction(comparator)) {
21148 comparator = function(actual, expected) {
21149 if (isUndefined(actual)) {
21150 // No substring matching against `undefined`
21151 return false;
21152 }
21153 if ((actual === null) || (expected === null)) {
21154 // No substring matching against `null`; only match against `null`
21155 return actual === expected;
21156 }
21157 if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) {
21158 // Should not compare primitives against objects, unless they have custom `toString` method
21159 return false;
21160 }
21161
21162 actual = lowercase('' + actual);
21163 expected = lowercase('' + expected);
21164 return actual.indexOf(expected) !== -1;
21165 };
21166 }
21167
21168 predicateFn = function(item) {
21169 if (shouldMatchPrimitives && !isObject(item)) {
21170 return deepCompare(item, expression[anyPropertyKey], comparator, anyPropertyKey, false);
21171 }
21172 return deepCompare(item, expression, comparator, anyPropertyKey, matchAgainstAnyProp);
21173 };
21174
21175 return predicateFn;
21176}
21177
21178function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstAnyProp, dontMatchWholeObject) {
21179 var actualType = getTypeForFilter(actual);

Callers 1

filterFilterFunction · 0.70

Calls 6

isObjectFunction · 0.70
isFunctionFunction · 0.70
isUndefinedFunction · 0.70
hasCustomToStringFunction · 0.70
lowercaseFunction · 0.70
deepCompareFunction · 0.70

Tested by

no test coverage detected