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

Function createPredicateFn

test/angular/1.5/angular.js:20531–20566  ·  view source on GitHub ↗
(expression, comparator, anyPropertyKey, matchAgainstAnyProp)

Source from the content-addressed store, hash-verified

20529
20530// Helper functions for `filterFilter`
20531function createPredicateFn(expression, comparator, anyPropertyKey, matchAgainstAnyProp) {
20532 var shouldMatchPrimitives = isObject(expression) && (anyPropertyKey in expression);
20533 var predicateFn;
20534
20535 if (comparator === true) {
20536 comparator = equals;
20537 } else if (!isFunction(comparator)) {
20538 comparator = function(actual, expected) {
20539 if (isUndefined(actual)) {
20540 // No substring matching against `undefined`
20541 return false;
20542 }
20543 if ((actual === null) || (expected === null)) {
20544 // No substring matching against `null`; only match against `null`
20545 return actual === expected;
20546 }
20547 if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) {
20548 // Should not compare primitives against objects, unless they have custom `toString` method
20549 return false;
20550 }
20551
20552 actual = lowercase('' + actual);
20553 expected = lowercase('' + expected);
20554 return actual.indexOf(expected) !== -1;
20555 };
20556 }
20557
20558 predicateFn = function(item) {
20559 if (shouldMatchPrimitives && !isObject(item)) {
20560 return deepCompare(item, expression[anyPropertyKey], comparator, anyPropertyKey, false);
20561 }
20562 return deepCompare(item, expression, comparator, anyPropertyKey, matchAgainstAnyProp);
20563 };
20564
20565 return predicateFn;
20566}
20567
20568function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstAnyProp, dontMatchWholeObject) {
20569 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