(expression, comparator, matchAgainstAnyProp)
| 16912 | |
| 16913 | // Helper functions for `filterFilter` |
| 16914 | function createPredicateFn(expression, comparator, matchAgainstAnyProp) { |
| 16915 | var shouldMatchPrimitives = isObject(expression) && ('$' in expression); |
| 16916 | var predicateFn; |
| 16917 | |
| 16918 | if (comparator === true) { |
| 16919 | comparator = equals; |
| 16920 | } else if (!isFunction(comparator)) { |
| 16921 | comparator = function(actual, expected) { |
| 16922 | if (isUndefined(actual)) { |
| 16923 | // No substring matching against `undefined` |
| 16924 | return false; |
| 16925 | } |
| 16926 | if ((actual === null) || (expected === null)) { |
| 16927 | // No substring matching against `null`; only match against `null` |
| 16928 | return actual === expected; |
| 16929 | } |
| 16930 | if (isObject(actual) || isObject(expected)) { |
| 16931 | // Prevent an object to be considered equal to a string like `'[object'` |
| 16932 | return false; |
| 16933 | } |
| 16934 | |
| 16935 | actual = lowercase('' + actual); |
| 16936 | expected = lowercase('' + expected); |
| 16937 | return actual.indexOf(expected) !== -1; |
| 16938 | }; |
| 16939 | } |
| 16940 | |
| 16941 | predicateFn = function(item) { |
| 16942 | if (shouldMatchPrimitives && !isObject(item)) { |
| 16943 | return deepCompare(item, expression.$, comparator, false); |
| 16944 | } |
| 16945 | return deepCompare(item, expression, comparator, matchAgainstAnyProp); |
| 16946 | }; |
| 16947 | |
| 16948 | return predicateFn; |
| 16949 | } |
| 16950 | |
| 16951 | function deepCompare(actual, expected, comparator, matchAgainstAnyProp, dontMatchWholeObject) { |
| 16952 | var actualType = (actual !== null) ? typeof actual : 'null'; |
no test coverage detected