MCPcopy Create free account
hub / github.com/RubyLouvre/anu / objEquiv

Function objEquiv

test/babel.js:6289–6322  ·  view source on GitHub ↗
(a, b, strict, actualVisitedObjects)

Source from the content-addressed store, hash-verified

6287 }
6288
6289 function objEquiv(a, b, strict, actualVisitedObjects) {
6290 if (a === null || a === undefined || b === null || b === undefined) return false;
6291 // if one is a primitive, the other must be same
6292 if (util.isPrimitive(a) || util.isPrimitive(b)) return a === b;
6293 if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;
6294 var aIsArgs = isArguments(a);
6295 var bIsArgs = isArguments(b);
6296 if (aIsArgs && !bIsArgs || !aIsArgs && bIsArgs) return false;
6297 if (aIsArgs) {
6298 a = pSlice.call(a);
6299 b = pSlice.call(b);
6300 return _deepEqual(a, b, strict);
6301 }
6302 var ka = objectKeys(a);
6303 var kb = objectKeys(b);
6304 var key, i;
6305 // having the same number of owned properties (keys incorporates
6306 // hasOwnProperty)
6307 if (ka.length !== kb.length) return false;
6308 //the same set of keys (although not necessarily the same order),
6309 ka.sort();
6310 kb.sort();
6311 //~~~cheap key test
6312 for (i = ka.length - 1; i >= 0; i--) {
6313 if (ka[i] !== kb[i]) return false;
6314 }
6315 //equivalent values for every corresponding key, and
6316 //~~~possibly expensive deep test
6317 for (i = ka.length - 1; i >= 0; i--) {
6318 key = ka[i];
6319 if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) return false;
6320 }
6321 return true;
6322 }
6323
6324 // 8. The non-equivalence assertion tests for any deep inequality.
6325 // assert.notDeepEqual(actual, expected, message_opt);

Callers 1

_deepEqualFunction · 0.85

Calls 2

isArgumentsFunction · 0.85
_deepEqualFunction · 0.85

Tested by

no test coverage detected