MCPcopy
hub / github.com/angular-ui/ui-router / createPredicateFn

Function createPredicateFn

test/angular/1.3/angular.js:16914–16949  ·  view source on GitHub ↗
(expression, comparator, matchAgainstAnyProp)

Source from the content-addressed store, hash-verified

16912
16913// Helper functions for `filterFilter`
16914function createPredicateFn(expression, comparator, matchAgainstAnyProp) {
16915 var shouldMatchPrimitives = isObject(expression) && ('$' in expression);
16916 var predicateFn;
16917
16918 if (comparator === true) {
16919 comparator = equals;
16920 } else if (!isFunction(comparator)) {
16921 comparator = function(actual, expected) {
16922 if (isUndefined(actual)) {
16923 // No substring matching against `undefined`
16924 return false;
16925 }
16926 if ((actual === null) || (expected === null)) {
16927 // No substring matching against `null`; only match against `null`
16928 return actual === expected;
16929 }
16930 if (isObject(actual) || isObject(expected)) {
16931 // Prevent an object to be considered equal to a string like `'[object'`
16932 return false;
16933 }
16934
16935 actual = lowercase('' + actual);
16936 expected = lowercase('' + expected);
16937 return actual.indexOf(expected) !== -1;
16938 };
16939 }
16940
16941 predicateFn = function(item) {
16942 if (shouldMatchPrimitives && !isObject(item)) {
16943 return deepCompare(item, expression.$, comparator, false);
16944 }
16945 return deepCompare(item, expression, comparator, matchAgainstAnyProp);
16946 };
16947
16948 return predicateFn;
16949}
16950
16951function deepCompare(actual, expected, comparator, matchAgainstAnyProp, dontMatchWholeObject) {
16952 var actualType = (actual !== null) ? typeof actual : 'null';

Callers 1

filterFilterFunction · 0.70

Calls 5

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

Tested by

no test coverage detected