(actual, expected, comparator, matchAgainstAnyProp, dontMatchWholeObject)
| 16949 | } |
| 16950 | |
| 16951 | function deepCompare(actual, expected, comparator, matchAgainstAnyProp, dontMatchWholeObject) { |
| 16952 | var actualType = (actual !== null) ? typeof actual : 'null'; |
| 16953 | var expectedType = (expected !== null) ? typeof expected : 'null'; |
| 16954 | |
| 16955 | if ((expectedType === 'string') && (expected.charAt(0) === '!')) { |
| 16956 | return !deepCompare(actual, expected.substring(1), comparator, matchAgainstAnyProp); |
| 16957 | } else if (isArray(actual)) { |
| 16958 | // In case `actual` is an array, consider it a match |
| 16959 | // if ANY of it's items matches `expected` |
| 16960 | return actual.some(function(item) { |
| 16961 | return deepCompare(item, expected, comparator, matchAgainstAnyProp); |
| 16962 | }); |
| 16963 | } |
| 16964 | |
| 16965 | switch (actualType) { |
| 16966 | case 'object': |
| 16967 | var key; |
| 16968 | if (matchAgainstAnyProp) { |
| 16969 | for (key in actual) { |
| 16970 | if ((key.charAt(0) !== '$') && deepCompare(actual[key], expected, comparator, true)) { |
| 16971 | return true; |
| 16972 | } |
| 16973 | } |
| 16974 | return dontMatchWholeObject ? false : deepCompare(actual, expected, comparator, false); |
| 16975 | } else if (expectedType === 'object') { |
| 16976 | for (key in expected) { |
| 16977 | var expectedVal = expected[key]; |
| 16978 | if (isFunction(expectedVal) || isUndefined(expectedVal)) { |
| 16979 | continue; |
| 16980 | } |
| 16981 | |
| 16982 | var matchAnyProperty = key === '$'; |
| 16983 | var actualVal = matchAnyProperty ? actual : actual[key]; |
| 16984 | if (!deepCompare(actualVal, expectedVal, comparator, matchAnyProperty, matchAnyProperty)) { |
| 16985 | return false; |
| 16986 | } |
| 16987 | } |
| 16988 | return true; |
| 16989 | } else { |
| 16990 | return comparator(actual, expected); |
| 16991 | } |
| 16992 | break; |
| 16993 | case 'function': |
| 16994 | return false; |
| 16995 | default: |
| 16996 | return comparator(actual, expected); |
| 16997 | } |
| 16998 | } |
| 16999 | |
| 17000 | /** |
| 17001 | * @ngdoc filter |
no test coverage detected