(expression, comparator, anyPropertyKey, matchAgainstAnyProp)
| 21463 | |
| 21464 | // Helper functions for `filterFilter` |
| 21465 | function createPredicateFn(expression, comparator, anyPropertyKey, matchAgainstAnyProp) { |
| 21466 | var shouldMatchPrimitives = isObject(expression) && (anyPropertyKey in expression); |
| 21467 | var predicateFn; |
| 21468 | |
| 21469 | if (comparator === true) { |
| 21470 | comparator = equals; |
| 21471 | } else if (!isFunction(comparator)) { |
| 21472 | comparator = function(actual, expected) { |
| 21473 | if (isUndefined(actual)) { |
| 21474 | // No substring matching against `undefined` |
| 21475 | return false; |
| 21476 | } |
| 21477 | if ((actual === null) || (expected === null)) { |
| 21478 | // No substring matching against `null`; only match against `null` |
| 21479 | return actual === expected; |
| 21480 | } |
| 21481 | if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) { |
| 21482 | // Should not compare primitives against objects, unless they have custom `toString` method |
| 21483 | return false; |
| 21484 | } |
| 21485 | |
| 21486 | actual = lowercase('' + actual); |
| 21487 | expected = lowercase('' + expected); |
| 21488 | return actual.indexOf(expected) !== -1; |
| 21489 | }; |
| 21490 | } |
| 21491 | |
| 21492 | predicateFn = function(item) { |
| 21493 | if (shouldMatchPrimitives && !isObject(item)) { |
| 21494 | return deepCompare(item, expression[anyPropertyKey], comparator, anyPropertyKey, false); |
| 21495 | } |
| 21496 | return deepCompare(item, expression, comparator, anyPropertyKey, matchAgainstAnyProp); |
| 21497 | }; |
| 21498 | |
| 21499 | return predicateFn; |
| 21500 | } |
| 21501 | |
| 21502 | function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstAnyProp, dontMatchWholeObject) { |
| 21503 | var actualType = getTypeForFilter(actual); |
no test coverage detected