(expression, comparator, matchAgainstAnyProp)
| 18280 | |
| 18281 | // Helper functions for `filterFilter` |
| 18282 | function createPredicateFn(expression, comparator, matchAgainstAnyProp) { |
| 18283 | var shouldMatchPrimitives = isObject(expression) && ('$' in expression); |
| 18284 | var predicateFn; |
| 18285 | |
| 18286 | if (comparator === true) { |
| 18287 | comparator = equals; |
| 18288 | } else if (!isFunction(comparator)) { |
| 18289 | comparator = function(actual, expected) { |
| 18290 | if (isUndefined(actual)) { |
| 18291 | // No substring matching against `undefined` |
| 18292 | return false; |
| 18293 | } |
| 18294 | if ((actual === null) || (expected === null)) { |
| 18295 | // No substring matching against `null`; only match against `null` |
| 18296 | return actual === expected; |
| 18297 | } |
| 18298 | if (isObject(expected) || (isObject(actual) && !hasCustomToString(actual))) { |
| 18299 | // Should not compare primitives against objects, unless they have custom `toString` method |
| 18300 | return false; |
| 18301 | } |
| 18302 | |
| 18303 | actual = lowercase('' + actual); |
| 18304 | expected = lowercase('' + expected); |
| 18305 | return actual.indexOf(expected) !== -1; |
| 18306 | }; |
| 18307 | } |
| 18308 | |
| 18309 | predicateFn = function(item) { |
| 18310 | if (shouldMatchPrimitives && !isObject(item)) { |
| 18311 | return deepCompare(item, expression.$, comparator, false); |
| 18312 | } |
| 18313 | return deepCompare(item, expression, comparator, matchAgainstAnyProp); |
| 18314 | }; |
| 18315 | |
| 18316 | return predicateFn; |
| 18317 | } |
| 18318 | |
| 18319 | function deepCompare(actual, expected, comparator, matchAgainstAnyProp, dontMatchWholeObject) { |
| 18320 | var actualType = getTypeForFilter(actual); |
no test coverage detected