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

Function createPredicateFn

lib/test/angular/1.5.0/angular.js:19311–19346  ·  view source on GitHub ↗
(expression, comparator, matchAgainstAnyProp)

Source from the content-addressed store, hash-verified

19309
19310// Helper functions for `filterFilter`
19311function createPredicateFn(expression, comparator, matchAgainstAnyProp) {
19312 var shouldMatchPrimitives = isObject(expression) && ('$' in expression);
19313 var predicateFn;
19314
19315 if (comparator === true) {
19316 comparator = equals;
19317 } else if (!isFunction(comparator)) {
19318 comparator = function(actual, expected) {
19319 if (isUndefined(actual)) {
19320 // No substring matching against `undefined`
19321 return false;
19322 }
19323 if ((actual === null) || (expected === null)) {
19324 // No substring matching against `null`; only match against `null`
19325 return actual === expected;
19326 }
19327 if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) {
19328 // Should not compare primitives against objects, unless they have custom `toString` method
19329 return false;
19330 }
19331
19332 actual = lowercase('' + actual);
19333 expected = lowercase('' + expected);
19334 return actual.indexOf(expected) !== -1;
19335 };
19336 }
19337
19338 predicateFn = function(item) {
19339 if (shouldMatchPrimitives && !isObject(item)) {
19340 return deepCompare(item, expression.$, comparator, false);
19341 }
19342 return deepCompare(item, expression, comparator, matchAgainstAnyProp);
19343 };
19344
19345 return predicateFn;
19346}
19347
19348function deepCompare(actual, expected, comparator, matchAgainstAnyProp, dontMatchWholeObject) {
19349 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