MCPcopy Create free account
hub / github.com/angular-ui/ui-grid / equals

Function equals

lib/test/angular/1.6.7/angular.js:1215–1255  ·  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

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

Callers 6

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

Calls 9

isDateFunction · 0.70
simpleCompareFunction · 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