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

Function createPredicateFn

test/angular/1.6/angular.js:21465–21500  ·  view source on GitHub ↗
(expression, comparator, anyPropertyKey, matchAgainstAnyProp)

Source from the content-addressed store, hash-verified

21463
21464// Helper functions for `filterFilter`
21465function createPredicateFn(expression, comparator, anyPropertyKey, matchAgainstAnyProp) {
21466 var shouldMatchPrimitives = isObject(expression) && (anyPropertyKey in expression);
21467 var predicateFn;
21468
21469 if (comparator === true) {
21470 comparator = equals;
21471 } else if (!isFunction(comparator)) {
21472 comparator = function(actual, expected) {
21473 if (isUndefined(actual)) {
21474 // No substring matching against `undefined`
21475 return false;
21476 }
21477 if ((actual === null) || (expected === null)) {
21478 // No substring matching against `null`; only match against `null`
21479 return actual === expected;
21480 }
21481 if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) {
21482 // Should not compare primitives against objects, unless they have custom `toString` method
21483 return false;
21484 }
21485
21486 actual = lowercase('' + actual);
21487 expected = lowercase('' + expected);
21488 return actual.indexOf(expected) !== -1;
21489 };
21490 }
21491
21492 predicateFn = function(item) {
21493 if (shouldMatchPrimitives && !isObject(item)) {
21494 return deepCompare(item, expression[anyPropertyKey], comparator, anyPropertyKey, false);
21495 }
21496 return deepCompare(item, expression, comparator, anyPropertyKey, matchAgainstAnyProp);
21497 };
21498
21499 return predicateFn;
21500}
21501
21502function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstAnyProp, dontMatchWholeObject) {
21503 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