(expression, comparator, matchAgainstAnyProp)
| 19309 | |
| 19310 | // Helper functions for `filterFilter` |
| 19311 | function createPredicateFn(expression, comparator, matchAgainstAnyProp) { |
| 19312 | var shouldMatchPrimitives = isObject(expression) && ('$' in expression); |
| 19313 | var predicateFn; |
| 19314 | |
| 19315 | if (comparator === true) { |
| 19316 | comparator = equals; |
| 19317 | } else if (!isFunction(comparator)) { |
| 19318 | comparator = function(actual, expected) { |
| 19319 | if (isUndefined(actual)) { |
| 19320 | // No substring matching against `undefined` |
| 19321 | return false; |
| 19322 | } |
| 19323 | if ((actual === null) || (expected === null)) { |
| 19324 | // No substring matching against `null`; only match against `null` |
| 19325 | return actual === expected; |
| 19326 | } |
| 19327 | if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) { |
| 19328 | // Should not compare primitives against objects, unless they have custom `toString` method |
| 19329 | return false; |
| 19330 | } |
| 19331 | |
| 19332 | actual = lowercase('' + actual); |
| 19333 | expected = lowercase('' + expected); |
| 19334 | return actual.indexOf(expected) !== -1; |
| 19335 | }; |
| 19336 | } |
| 19337 | |
| 19338 | predicateFn = function(item) { |
| 19339 | if (shouldMatchPrimitives && !isObject(item)) { |
| 19340 | return deepCompare(item, expression.$, comparator, false); |
| 19341 | } |
| 19342 | return deepCompare(item, expression, comparator, matchAgainstAnyProp); |
| 19343 | }; |
| 19344 | |
| 19345 | return predicateFn; |
| 19346 | } |
| 19347 | |
| 19348 | function deepCompare(actual, expected, comparator, matchAgainstAnyProp, dontMatchWholeObject) { |
| 19349 | var actualType = getTypeForFilter(actual); |
no test coverage detected