MCPcopy Create free account
hub / github.com/Lobos/react-ui / objEquiv

Function objEquiv

docs/lib/ReactRouter.js:4445–4496  ·  view source on GitHub ↗
(a, b, opts)

Source from the content-addressed store, hash-verified

4443 }
4444
4445 function objEquiv(a, b, opts) {
4446 var i, key;
4447 if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
4448 return false;
4449 // an identical 'prototype' property.
4450 if (a.prototype !== b.prototype) return false;
4451 //~~~I've managed to break Object.keys through screwy arguments passing.
4452 // Converting to array solves the problem.
4453 if (isArguments(a)) {
4454 if (!isArguments(b)) {
4455 return false;
4456 }
4457 a = pSlice.call(a);
4458 b = pSlice.call(b);
4459 return deepEqual(a, b, opts);
4460 }
4461 if (isBuffer(a)) {
4462 if (!isBuffer(b)) {
4463 return false;
4464 }
4465 if (a.length !== b.length) return false;
4466 for (i = 0; i < a.length; i++) {
4467 if (a[i] !== b[i]) return false;
4468 }
4469 return true;
4470 }
4471 try {
4472 var ka = objectKeys(a),
4473 kb = objectKeys(b);
4474 } catch (e) {//happens when one is a string literal and the other isn't
4475 return false;
4476 }
4477 // having the same number of owned properties (keys incorporates
4478 // hasOwnProperty)
4479 if (ka.length != kb.length)
4480 return false;
4481 //the same set of keys (although not necessarily the same order),
4482 ka.sort();
4483 kb.sort();
4484 //~~~cheap key test
4485 for (i = ka.length - 1; i >= 0; i--) {
4486 if (ka[i] != kb[i])
4487 return false;
4488 }
4489 //equivalent values for every corresponding key, and
4490 //~~~possibly expensive deep test
4491 for (i = ka.length - 1; i >= 0; i--) {
4492 key = ka[i];
4493 if (!deepEqual(a[key], b[key], opts)) return false;
4494 }
4495 return typeof a === typeof b;
4496 }
4497
4498
4499/***/ },

Callers 1

ReactRouter.jsFile · 0.85

Calls 3

isUndefinedOrNullFunction · 0.85
deepEqualFunction · 0.85
isBufferFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…