MCPcopy Index your code
hub / github.com/angular-ui/ui-router / equals

Function equals

test/angular/1.7/angular.js:1222–1262  ·  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

1220 </example>
1221 */
1222function equals(o1, o2) {
1223 if (o1 === o2) return true;
1224 if (o1 === null || o2 === null) return false;
1225 // eslint-disable-next-line no-self-compare
1226 if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN
1227 var t1 = typeof o1, t2 = typeof o2, length, key, keySet;
1228 if (t1 === t2 && t1 === 'object') {
1229 if (isArray(o1)) {
1230 if (!isArray(o2)) return false;
1231 if ((length = o1.length) === o2.length) {
1232 for (key = 0; key < length; key++) {
1233 if (!equals(o1[key], o2[key])) return false;
1234 }
1235 return true;
1236 }
1237 } else if (isDate(o1)) {
1238 if (!isDate(o2)) return false;
1239 return simpleCompare(o1.getTime(), o2.getTime());
1240 } else if (isRegExp(o1)) {
1241 if (!isRegExp(o2)) return false;
1242 return o1.toString() === o2.toString();
1243 } else {
1244 if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2) ||
1245 isArray(o2) || isDate(o2) || isRegExp(o2)) return false;
1246 keySet = createMap();
1247 for (key in o1) {
1248 if (key.charAt(0) === '$' || isFunction(o1[key])) continue;
1249 if (!equals(o1[key], o2[key])) return false;
1250 keySet[key] = true;
1251 }
1252 for (key in o2) {
1253 if (!(key in keySet) &&
1254 key.charAt(0) !== '$' &&
1255 isDefined(o2[key]) &&
1256 !isFunction(o2[key])) return false;
1257 }
1258 return true;
1259 }
1260 }
1261 return false;
1262}
1263
1264var csp = function() {
1265 if (!isDefined(csp.rules)) {

Callers 6

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

Calls 9

isArrayFunction · 0.85
isDateFunction · 0.70
simpleCompareFunction · 0.70
isRegExpFunction · 0.70
isScopeFunction · 0.70
isWindowFunction · 0.70
createMapFunction · 0.70
isFunctionFunction · 0.70
isDefinedFunction · 0.70

Tested by

no test coverage detected