(expression, comparator, matchAgainstAnyProp)
| 18420 | |
| 18421 | // Helper functions for `filterFilter` |
| 18422 | function createPredicateFn(expression, comparator, matchAgainstAnyProp) { |
| 18423 | var shouldMatchPrimitives = isObject(expression) && ('$' in expression); |
| 18424 | var predicateFn; |
| 18425 | |
| 18426 | if (comparator === true) { |
| 18427 | comparator = equals; |
| 18428 | } else if (!isFunction(comparator)) { |
| 18429 | comparator = function(actual, expected) { |
| 18430 | if (isUndefined(actual)) { |
| 18431 | // No substring matching against `undefined` |
| 18432 | return false; |
| 18433 | } |
| 18434 | if ((actual === null) || (expected === null)) { |
| 18435 | // No substring matching against `null`; only match against `null` |
| 18436 | return actual === expected; |
| 18437 | } |
| 18438 | if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) { |
| 18439 | // Should not compare primitives against objects, unless they have custom `toString` method |
| 18440 | return false; |
| 18441 | } |
| 18442 | |
| 18443 | actual = lowercase('' + actual); |
| 18444 | expected = lowercase('' + expected); |
| 18445 | return actual.indexOf(expected) !== -1; |
| 18446 | }; |
| 18447 | } |
| 18448 | |
| 18449 | predicateFn = function(item) { |
| 18450 | if (shouldMatchPrimitives && !isObject(item)) { |
| 18451 | return deepCompare(item, expression.$, comparator, false); |
| 18452 | } |
| 18453 | return deepCompare(item, expression, comparator, matchAgainstAnyProp); |
| 18454 | }; |
| 18455 | |
| 18456 | return predicateFn; |
| 18457 | } |
| 18458 | |
| 18459 | function deepCompare(actual, expected, comparator, matchAgainstAnyProp, dontMatchWholeObject) { |
| 18460 | var actualType = getTypeForFilter(actual); |
no test coverage detected