(expression, comparator, anyPropertyKey, matchAgainstAnyProp)
| 22360 | |
| 22361 | // Helper functions for `filterFilter` |
| 22362 | function createPredicateFn(expression, comparator, anyPropertyKey, matchAgainstAnyProp) { |
| 22363 | var shouldMatchPrimitives = isObject(expression) && (anyPropertyKey in expression); |
| 22364 | var predicateFn; |
| 22365 | |
| 22366 | if (comparator === true) { |
| 22367 | comparator = equals; |
| 22368 | } else if (!isFunction(comparator)) { |
| 22369 | comparator = function(actual, expected) { |
| 22370 | if (isUndefined(actual)) { |
| 22371 | // No substring matching against `undefined` |
| 22372 | return false; |
| 22373 | } |
| 22374 | if ((actual === null) || (expected === null)) { |
| 22375 | // No substring matching against `null`; only match against `null` |
| 22376 | return actual === expected; |
| 22377 | } |
| 22378 | if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) { |
| 22379 | // Should not compare primitives against objects, unless they have custom `toString` method |
| 22380 | return false; |
| 22381 | } |
| 22382 | |
| 22383 | actual = lowercase('' + actual); |
| 22384 | expected = lowercase('' + expected); |
| 22385 | return actual.indexOf(expected) !== -1; |
| 22386 | }; |
| 22387 | } |
| 22388 | |
| 22389 | predicateFn = function(item) { |
| 22390 | if (shouldMatchPrimitives && !isObject(item)) { |
| 22391 | return deepCompare(item, expression[anyPropertyKey], comparator, anyPropertyKey, false); |
| 22392 | } |
| 22393 | return deepCompare(item, expression, comparator, anyPropertyKey, matchAgainstAnyProp); |
| 22394 | }; |
| 22395 | |
| 22396 | return predicateFn; |
| 22397 | } |
| 22398 | |
| 22399 | function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstAnyProp, dontMatchWholeObject) { |
| 22400 | var actualType = getTypeForFilter(actual); |
no test coverage detected