MCPcopy Create free account
hub / github.com/angular-ui/ui-grid / createPredicateFn

Function createPredicateFn

lib/test/angular/1.8.0/angular.js:22362–22397  ·  view source on GitHub ↗
(expression, comparator, anyPropertyKey, matchAgainstAnyProp)

Source from the content-addressed store, hash-verified

22360
22361// Helper functions for `filterFilter`
22362function createPredicateFn(expression, comparator, anyPropertyKey, matchAgainstAnyProp) {
22363 var shouldMatchPrimitives = isObject(expression) && (anyPropertyKey in expression);
22364 var predicateFn;
22365
22366 if (comparator === true) {
22367 comparator = equals;
22368 } else if (!isFunction(comparator)) {
22369 comparator = function(actual, expected) {
22370 if (isUndefined(actual)) {
22371 // No substring matching against `undefined`
22372 return false;
22373 }
22374 if ((actual === null) || (expected === null)) {
22375 // No substring matching against `null`; only match against `null`
22376 return actual === expected;
22377 }
22378 if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) {
22379 // Should not compare primitives against objects, unless they have custom `toString` method
22380 return false;
22381 }
22382
22383 actual = lowercase('' + actual);
22384 expected = lowercase('' + expected);
22385 return actual.indexOf(expected) !== -1;
22386 };
22387 }
22388
22389 predicateFn = function(item) {
22390 if (shouldMatchPrimitives && !isObject(item)) {
22391 return deepCompare(item, expression[anyPropertyKey], comparator, anyPropertyKey, false);
22392 }
22393 return deepCompare(item, expression, comparator, anyPropertyKey, matchAgainstAnyProp);
22394 };
22395
22396 return predicateFn;
22397}
22398
22399function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstAnyProp, dontMatchWholeObject) {
22400 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