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

Function createPredicateFn

test/angular/1.7/angular.js:22297–22332  ·  view source on GitHub ↗
(expression, comparator, anyPropertyKey, matchAgainstAnyProp)

Source from the content-addressed store, hash-verified

22295
22296// Helper functions for `filterFilter`
22297function createPredicateFn(expression, comparator, anyPropertyKey, matchAgainstAnyProp) {
22298 var shouldMatchPrimitives = isObject(expression) && (anyPropertyKey in expression);
22299 var predicateFn;
22300
22301 if (comparator === true) {
22302 comparator = equals;
22303 } else if (!isFunction(comparator)) {
22304 comparator = function(actual, expected) {
22305 if (isUndefined(actual)) {
22306 // No substring matching against `undefined`
22307 return false;
22308 }
22309 if ((actual === null) || (expected === null)) {
22310 // No substring matching against `null`; only match against `null`
22311 return actual === expected;
22312 }
22313 if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) {
22314 // Should not compare primitives against objects, unless they have custom `toString` method
22315 return false;
22316 }
22317
22318 actual = lowercase('' + actual);
22319 expected = lowercase('' + expected);
22320 return actual.indexOf(expected) !== -1;
22321 };
22322 }
22323
22324 predicateFn = function(item) {
22325 if (shouldMatchPrimitives && !isObject(item)) {
22326 return deepCompare(item, expression[anyPropertyKey], comparator, anyPropertyKey, false);
22327 }
22328 return deepCompare(item, expression, comparator, anyPropertyKey, matchAgainstAnyProp);
22329 };
22330
22331 return predicateFn;
22332}
22333
22334function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstAnyProp, dontMatchWholeObject) {
22335 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