(expression, comparator, anyPropertyKey, matchAgainstAnyProp)
| 21574 | |
| 21575 | // Helper functions for `filterFilter` |
| 21576 | function createPredicateFn(expression, comparator, anyPropertyKey, matchAgainstAnyProp) { |
| 21577 | var shouldMatchPrimitives = isObject(expression) && (anyPropertyKey in expression); |
| 21578 | var predicateFn; |
| 21579 | |
| 21580 | if (comparator === true) { |
| 21581 | comparator = equals; |
| 21582 | } else if (!isFunction(comparator)) { |
| 21583 | comparator = function(actual, expected) { |
| 21584 | if (isUndefined(actual)) { |
| 21585 | // No substring matching against `undefined` |
| 21586 | return false; |
| 21587 | } |
| 21588 | if ((actual === null) || (expected === null)) { |
| 21589 | // No substring matching against `null`; only match against `null` |
| 21590 | return actual === expected; |
| 21591 | } |
| 21592 | if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) { |
| 21593 | // Should not compare primitives against objects, unless they have custom `toString` method |
| 21594 | return false; |
| 21595 | } |
| 21596 | |
| 21597 | actual = lowercase('' + actual); |
| 21598 | expected = lowercase('' + expected); |
| 21599 | return actual.indexOf(expected) !== -1; |
| 21600 | }; |
| 21601 | } |
| 21602 | |
| 21603 | predicateFn = function(item) { |
| 21604 | if (shouldMatchPrimitives && !isObject(item)) { |
| 21605 | return deepCompare(item, expression[anyPropertyKey], comparator, anyPropertyKey, false); |
| 21606 | } |
| 21607 | return deepCompare(item, expression, comparator, anyPropertyKey, matchAgainstAnyProp); |
| 21608 | }; |
| 21609 | |
| 21610 | return predicateFn; |
| 21611 | } |
| 21612 | |
| 21613 | function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstAnyProp, dontMatchWholeObject) { |
| 21614 | var actualType = getTypeForFilter(actual); |
no test coverage detected