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

Function equals

lib/test/angular/1.4.3/angular.js:1013–1053  ·  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

1011 * @returns {boolean} True if arguments are equal.
1012 */
1013function equals(o1, o2) {
1014 if (o1 === o2) return true;
1015 if (o1 === null || o2 === null) return false;
1016 if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN
1017 var t1 = typeof o1, t2 = typeof o2, length, key, keySet;
1018 if (t1 == t2) {
1019 if (t1 == 'object') {
1020 if (isArray(o1)) {
1021 if (!isArray(o2)) return false;
1022 if ((length = o1.length) == o2.length) {
1023 for (key = 0; key < length; key++) {
1024 if (!equals(o1[key], o2[key])) return false;
1025 }
1026 return true;
1027 }
1028 } else if (isDate(o1)) {
1029 if (!isDate(o2)) return false;
1030 return equals(o1.getTime(), o2.getTime());
1031 } else if (isRegExp(o1)) {
1032 return isRegExp(o2) ? o1.toString() == o2.toString() : false;
1033 } else {
1034 if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2) ||
1035 isArray(o2) || isDate(o2) || isRegExp(o2)) return false;
1036 keySet = createMap();
1037 for (key in o1) {
1038 if (key.charAt(0) === '$' || isFunction(o1[key])) continue;
1039 if (!equals(o1[key], o2[key])) return false;
1040 keySet[key] = true;
1041 }
1042 for (key in o2) {
1043 if (!(key in keySet) &&
1044 key.charAt(0) !== '$' &&
1045 o2[key] !== undefined &&
1046 !isFunction(o2[key])) return false;
1047 }
1048 return true;
1049 }
1050 }
1051 }
1052 return false;
1053}
1054
1055var csp = function() {
1056 if (isDefined(csp.isActive_)) return csp.isActive_;

Callers 6

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

Calls 7

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

Tested by

no test coverage detected