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

Function equals

lib/test/angular/1.5.0/angular.js:1048–1087  ·  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

1046 * @returns {boolean} True if arguments are equal.
1047 */
1048function equals(o1, o2) {
1049 if (o1 === o2) return true;
1050 if (o1 === null || o2 === null) return false;
1051 if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN
1052 var t1 = typeof o1, t2 = typeof o2, length, key, keySet;
1053 if (t1 == t2 && t1 == 'object') {
1054 if (isArray(o1)) {
1055 if (!isArray(o2)) return false;
1056 if ((length = o1.length) == o2.length) {
1057 for (key = 0; key < length; key++) {
1058 if (!equals(o1[key], o2[key])) return false;
1059 }
1060 return true;
1061 }
1062 } else if (isDate(o1)) {
1063 if (!isDate(o2)) return false;
1064 return equals(o1.getTime(), o2.getTime());
1065 } else if (isRegExp(o1)) {
1066 if (!isRegExp(o2)) return false;
1067 return o1.toString() == o2.toString();
1068 } else {
1069 if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2) ||
1070 isArray(o2) || isDate(o2) || isRegExp(o2)) return false;
1071 keySet = createMap();
1072 for (key in o1) {
1073 if (key.charAt(0) === '$' || isFunction(o1[key])) continue;
1074 if (!equals(o1[key], o2[key])) return false;
1075 keySet[key] = true;
1076 }
1077 for (key in o2) {
1078 if (!(key in keySet) &&
1079 key.charAt(0) !== '$' &&
1080 isDefined(o2[key]) &&
1081 !isFunction(o2[key])) return false;
1082 }
1083 return true;
1084 }
1085 }
1086 return false;
1087}
1088
1089var csp = function() {
1090 if (!isDefined(csp.rules)) {

Callers 6

cacheStateFunction · 0.70
$RootScopeProviderFunction · 0.70
checkboxInputTypeFunction · 0.70
ngClassWatchActionFunction · 0.70
updateOptionsFunction · 0.70
selectPreLinkFunction · 0.70

Calls 8

isDateFunction · 0.70
isRegExpFunction · 0.70
isScopeFunction · 0.70
isWindowFunction · 0.70
createMapFunction · 0.70
isFunctionFunction · 0.70
isDefinedFunction · 0.70
isArrayFunction · 0.50

Tested by

no test coverage detected