MCPcopy
hub / github.com/angular-ui/ui-router / equals

Function equals

test/angular/1.3/angular.js:908–948  ·  view source on GitHub ↗

* @ngdoc function * @name angular.equals * @module ng * @kind function * * @description * Determines if two objects or two values are equivalent. Supports value types, regular * expressions, arrays and objects. * * Two objects or values are considered equivalent if at least one of the follo

(o1, o2)

Source from the content-addressed store, hash-verified

906 * @returns {boolean} True if arguments are equal.
907 */
908function equals(o1, o2) {
909 if (o1 === o2) return true;
910 if (o1 === null || o2 === null) return false;
911 if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN
912 var t1 = typeof o1, t2 = typeof o2, length, key, keySet;
913 if (t1 == t2) {
914 if (t1 == 'object') {
915 if (isArray(o1)) {
916 if (!isArray(o2)) return false;
917 if ((length = o1.length) == o2.length) {
918 for (key = 0; key < length; key++) {
919 if (!equals(o1[key], o2[key])) return false;
920 }
921 return true;
922 }
923 } else if (isDate(o1)) {
924 if (!isDate(o2)) return false;
925 return equals(o1.getTime(), o2.getTime());
926 } else if (isRegExp(o1)) {
927 return isRegExp(o2) ? o1.toString() == o2.toString() : false;
928 } else {
929 if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2) ||
930 isArray(o2) || isDate(o2) || isRegExp(o2)) return false;
931 keySet = {};
932 for (key in o1) {
933 if (key.charAt(0) === '$' || isFunction(o1[key])) continue;
934 if (!equals(o1[key], o2[key])) return false;
935 keySet[key] = true;
936 }
937 for (key in o2) {
938 if (!keySet.hasOwnProperty(key) &&
939 key.charAt(0) !== '$' &&
940 o2[key] !== undefined &&
941 !isFunction(o2[key])) return false;
942 }
943 return true;
944 }
945 }
946 }
947 return false;
948}
949
950var csp = function() {
951 if (isDefined(csp.isActive_)) return csp.isActive_;

Callers 5

cacheStateFunction · 0.70
$RootScopeProviderFunction · 0.70
checkboxInputTypeFunction · 0.70
ngClassWatchActionFunction · 0.70
setupAsMultipleFunction · 0.70

Calls 6

isArrayFunction · 0.85
isDateFunction · 0.70
isRegExpFunction · 0.70
isScopeFunction · 0.70
isWindowFunction · 0.70
isFunctionFunction · 0.70

Tested by

no test coverage detected