(expression, comparator, matchAgainstAnyProp)
| 18833 | |
| 18834 | // Helper functions for `filterFilter` |
| 18835 | function createPredicateFn(expression, comparator, matchAgainstAnyProp) { |
| 18836 | var shouldMatchPrimitives = isObject(expression) && ('$' in expression); |
| 18837 | var predicateFn; |
| 18838 | |
| 18839 | if (comparator === true) { |
| 18840 | comparator = equals; |
| 18841 | } else if (!isFunction(comparator)) { |
| 18842 | comparator = function(actual, expected) { |
| 18843 | if (isUndefined(actual)) { |
| 18844 | // No substring matching against `undefined` |
| 18845 | return false; |
| 18846 | } |
| 18847 | if ((actual === null) || (expected === null)) { |
| 18848 | // No substring matching against `null`; only match against `null` |
| 18849 | return actual === expected; |
| 18850 | } |
| 18851 | if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) { |
| 18852 | // Should not compare primitives against objects, unless they have custom `toString` method |
| 18853 | return false; |
| 18854 | } |
| 18855 | |
| 18856 | actual = lowercase('' + actual); |
| 18857 | expected = lowercase('' + expected); |
| 18858 | return actual.indexOf(expected) !== -1; |
| 18859 | }; |
| 18860 | } |
| 18861 | |
| 18862 | predicateFn = function(item) { |
| 18863 | if (shouldMatchPrimitives && !isObject(item)) { |
| 18864 | return deepCompare(item, expression.$, comparator, false); |
| 18865 | } |
| 18866 | return deepCompare(item, expression, comparator, matchAgainstAnyProp); |
| 18867 | }; |
| 18868 | |
| 18869 | return predicateFn; |
| 18870 | } |
| 18871 | |
| 18872 | function deepCompare(actual, expected, comparator, matchAgainstAnyProp, dontMatchWholeObject) { |
| 18873 | var actualType = getTypeForFilter(actual); |
no test coverage detected