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

Function createPredicateFn

lib/test/angular/1.4.3/angular.js:18282–18317  ·  view source on GitHub ↗
(expression, comparator, matchAgainstAnyProp)

Source from the content-addressed store, hash-verified

18280
18281// Helper functions for `filterFilter`
18282function createPredicateFn(expression, comparator, matchAgainstAnyProp) {
18283 var shouldMatchPrimitives = isObject(expression) && ('$' in expression);
18284 var predicateFn;
18285
18286 if (comparator === true) {
18287 comparator = equals;
18288 } else if (!isFunction(comparator)) {
18289 comparator = function(actual, expected) {
18290 if (isUndefined(actual)) {
18291 // No substring matching against `undefined`
18292 return false;
18293 }
18294 if ((actual === null) || (expected === null)) {
18295 // No substring matching against `null`; only match against `null`
18296 return actual === expected;
18297 }
18298 if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) {
18299 // Should not compare primitives against objects, unless they have custom `toString` method
18300 return false;
18301 }
18302
18303 actual = lowercase('' + actual);
18304 expected = lowercase('' + expected);
18305 return actual.indexOf(expected) !== -1;
18306 };
18307 }
18308
18309 predicateFn = function(item) {
18310 if (shouldMatchPrimitives && !isObject(item)) {
18311 return deepCompare(item, expression.$, comparator, false);
18312 }
18313 return deepCompare(item, expression, comparator, matchAgainstAnyProp);
18314 };
18315
18316 return predicateFn;
18317}
18318
18319function deepCompare(actual, expected, comparator, matchAgainstAnyProp, dontMatchWholeObject) {
18320 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