MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / equals

Function equals

web/static/bower_components/angular/angular.js:1017–1057  ·  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

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

Callers 6

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

Calls 7

isDateFunction · 0.85
isRegExpFunction · 0.85
isScopeFunction · 0.85
isWindowFunction · 0.85
createMapFunction · 0.85
isFunctionFunction · 0.85
isDefinedFunction · 0.85

Tested by

no test coverage detected