(expression, comparator, anyPropertyKey, matchAgainstAnyProp)
| 20529 | |
| 20530 | // Helper functions for `filterFilter` |
| 20531 | function createPredicateFn(expression, comparator, anyPropertyKey, matchAgainstAnyProp) { |
| 20532 | var shouldMatchPrimitives = isObject(expression) && (anyPropertyKey in expression); |
| 20533 | var predicateFn; |
| 20534 | |
| 20535 | if (comparator === true) { |
| 20536 | comparator = equals; |
| 20537 | } else if (!isFunction(comparator)) { |
| 20538 | comparator = function(actual, expected) { |
| 20539 | if (isUndefined(actual)) { |
| 20540 | // No substring matching against `undefined` |
| 20541 | return false; |
| 20542 | } |
| 20543 | if ((actual === null) || (expected === null)) { |
| 20544 | // No substring matching against `null`; only match against `null` |
| 20545 | return actual === expected; |
| 20546 | } |
| 20547 | if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) { |
| 20548 | // Should not compare primitives against objects, unless they have custom `toString` method |
| 20549 | return false; |
| 20550 | } |
| 20551 | |
| 20552 | actual = lowercase('' + actual); |
| 20553 | expected = lowercase('' + expected); |
| 20554 | return actual.indexOf(expected) !== -1; |
| 20555 | }; |
| 20556 | } |
| 20557 | |
| 20558 | predicateFn = function(item) { |
| 20559 | if (shouldMatchPrimitives && !isObject(item)) { |
| 20560 | return deepCompare(item, expression[anyPropertyKey], comparator, anyPropertyKey, false); |
| 20561 | } |
| 20562 | return deepCompare(item, expression, comparator, anyPropertyKey, matchAgainstAnyProp); |
| 20563 | }; |
| 20564 | |
| 20565 | return predicateFn; |
| 20566 | } |
| 20567 | |
| 20568 | function deepCompare(actual, expected, comparator, anyPropertyKey, matchAgainstAnyProp, dontMatchWholeObject) { |
| 20569 | var actualType = getTypeForFilter(actual); |
no test coverage detected