(expression, comparator, anyPropertyKey, matchAgainstAnyProp)
| 22295 | |
| 22296 | // Helper functions for `filterFilter` |
| 22297 | function createPredicateFn(expression, comparator, anyPropertyKey, matchAgainstAnyProp) { |
| 22298 | var shouldMatchPrimitives = isObject(expression) && (anyPropertyKey in expression); |
| 22299 | var predicateFn; |
| 22300 | |
| 22301 | if (comparator === true) { |
| 22302 | comparator = equals; |
| 22303 | } else if (!isFunction(comparator)) { |
| 22304 | comparator = function(actual, expected) { |
| 22305 | if (isUndefined(actual)) { |
| 22306 | // No substring matching against `undefined` |
| 22307 | return false; |
| 22308 | } |
| 22309 | if ((actual === null) || (expected === null)) { |
| 22310 | // No substring matching against `null`; only match against `null` |
| 22311 | return actual === expected; |
| 22312 | } |
| 22313 | if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) { |
| 22314 | // Should not compare primitives against objects, unless they have custom `toString` method |
| 22315 | return false; |
| 22316 | } |
| 22317 | |
| 22318 | actual = lowercase('' + actual); |
| 22319 | expected = lowercase('' + expected); |
| 22320 | return actual.indexOf(expected) !== -1; |
| 22321 | }; |
| 22322 | } |
| 22323 | |
| 22324 | predicateFn = function(item) { |
| 22325 | if (shouldMatchPrimitives && !isObject(item)) { |
| 22326 | return deepCompare(item, expression[anyPropertyKey], comparator, anyPropertyKey, false); |
| 22327 | } |
| 22328 | return deepCompare(item, expression, comparator, anyPropertyKey, matchAgainstAnyProp); |
| 22329 | }; |
| 22330 | |
| 22331 | return predicateFn; |
| 22332 | } |
| 22333 | |
| 22334 | function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstAnyProp, dontMatchWholeObject) { |
| 22335 | var actualType = getTypeForFilter(actual); |
no test coverage detected