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

Function createPredicateFn

lib/test/angular/1.7.0/angular.js:21576–21611  ·  view source on GitHub ↗
(expression, comparator, anyPropertyKey, matchAgainstAnyProp)

Source from the content-addressed store, hash-verified

21574
21575// Helper functions for `filterFilter`
21576function createPredicateFn(expression, comparator, anyPropertyKey, matchAgainstAnyProp) {
21577 var shouldMatchPrimitives = isObject(expression) && (anyPropertyKey in expression);
21578 var predicateFn;
21579
21580 if (comparator === true) {
21581 comparator = equals;
21582 } else if (!isFunction(comparator)) {
21583 comparator = function(actual, expected) {
21584 if (isUndefined(actual)) {
21585 // No substring matching against `undefined`
21586 return false;
21587 }
21588 if ((actual === null) || (expected === null)) {
21589 // No substring matching against `null`; only match against `null`
21590 return actual === expected;
21591 }
21592 if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) {
21593 // Should not compare primitives against objects, unless they have custom `toString` method
21594 return false;
21595 }
21596
21597 actual = lowercase('' + actual);
21598 expected = lowercase('' + expected);
21599 return actual.indexOf(expected) !== -1;
21600 };
21601 }
21602
21603 predicateFn = function(item) {
21604 if (shouldMatchPrimitives && !isObject(item)) {
21605 return deepCompare(item, expression[anyPropertyKey], comparator, anyPropertyKey, false);
21606 }
21607 return deepCompare(item, expression, comparator, anyPropertyKey, matchAgainstAnyProp);
21608 };
21609
21610 return predicateFn;
21611}
21612
21613function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstAnyProp, dontMatchWholeObject) {
21614 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