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

Function equals

test/angular/1.6/angular.js:1225–1265  ·  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

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