MCPcopy Create free account
hub / github.com/bclinkinbeard/angular / equals

Function equals

test/fixtures/foo.js:977–1016  ·  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

975 * @returns {boolean} True if arguments are equal.
976 */
977function equals(o1, o2) {
978 if (o1 === o2) return true;
979 if (o1 === null || o2 === null) return false;
980 if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN
981 var t1 = typeof o1, t2 = typeof o2, length, key, keySet;
982 if (t1 == t2) {
983 if (t1 == 'object') {
984 if (isArray(o1)) {
985 if (!isArray(o2)) return false;
986 if ((length = o1.length) == o2.length) {
987 for(key=0; key<length; key++) {
988 if (!equals(o1[key], o2[key])) return false;
989 }
990 return true;
991 }
992 } else if (isDate(o1)) {
993 if (!isDate(o2)) return false;
994 return (isNaN(o1.getTime()) && isNaN(o2.getTime())) || (o1.getTime() === o2.getTime());
995 } else if (isRegExp(o1) && isRegExp(o2)) {
996 return o1.toString() == o2.toString();
997 } else {
998 if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2) || isArray(o2)) return false;
999 keySet = {};
1000 for(key in o1) {
1001 if (key.charAt(0) === '$' || isFunction(o1[key])) continue;
1002 if (!equals(o1[key], o2[key])) return false;
1003 keySet[key] = true;
1004 }
1005 for(key in o2) {
1006 if (!keySet.hasOwnProperty(key) &&
1007 key.charAt(0) !== '$' &&
1008 o2[key] !== undefined &&
1009 !isFunction(o2[key])) return false;
1010 }
1011 return true;
1012 }
1013 }
1014 }
1015 return false;
1016}
1017
1018var csp = function() {
1019 if (isDefined(csp.isActive_)) return csp.isActive_;

Callers 3

$RootScopeProviderFunction · 0.85
ngClassWatchActionFunction · 0.85
setupAsMultipleFunction · 0.85

Calls 5

isDateFunction · 0.85
isRegExpFunction · 0.85
isScopeFunction · 0.85
isWindowFunction · 0.85
isFunctionFunction · 0.85

Tested by

no test coverage detected