(expression, comparator, anyPropertyKey, matchAgainstAnyProp)
| 21139 | |
| 21140 | // Helper functions for `filterFilter` |
| 21141 | function createPredicateFn(expression, comparator, anyPropertyKey, matchAgainstAnyProp) { |
| 21142 | var shouldMatchPrimitives = isObject(expression) && (anyPropertyKey in expression); |
| 21143 | var predicateFn; |
| 21144 | |
| 21145 | if (comparator === true) { |
| 21146 | comparator = equals; |
| 21147 | } else if (!isFunction(comparator)) { |
| 21148 | comparator = function(actual, expected) { |
| 21149 | if (isUndefined(actual)) { |
| 21150 | // No substring matching against `undefined` |
| 21151 | return false; |
| 21152 | } |
| 21153 | if ((actual === null) || (expected === null)) { |
| 21154 | // No substring matching against `null`; only match against `null` |
| 21155 | return actual === expected; |
| 21156 | } |
| 21157 | if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) { |
| 21158 | // Should not compare primitives against objects, unless they have custom `toString` method |
| 21159 | return false; |
| 21160 | } |
| 21161 | |
| 21162 | actual = lowercase('' + actual); |
| 21163 | expected = lowercase('' + expected); |
| 21164 | return actual.indexOf(expected) !== -1; |
| 21165 | }; |
| 21166 | } |
| 21167 | |
| 21168 | predicateFn = function(item) { |
| 21169 | if (shouldMatchPrimitives && !isObject(item)) { |
| 21170 | return deepCompare(item, expression[anyPropertyKey], comparator, anyPropertyKey, false); |
| 21171 | } |
| 21172 | return deepCompare(item, expression, comparator, anyPropertyKey, matchAgainstAnyProp); |
| 21173 | }; |
| 21174 | |
| 21175 | return predicateFn; |
| 21176 | } |
| 21177 | |
| 21178 | function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstAnyProp, dontMatchWholeObject) { |
| 21179 | var actualType = getTypeForFilter(actual); |
no test coverage detected