3 var eq = require('./eq')
4 , isPlainObject = require('./is-plain-object')
5 , value = require('./valid-value')
7 , isArray = Array.isArray, keys = Object.keys
8 , propertyIsEnumerable = Object.prototype.propertyIsEnumerable
10 , eqArr, eqVal, eqObj;
12 eqArr = function (a, b, recMap) {
14 if (l !== b.length) return false;
15 for (i = 0; i < l; ++i) {
16 if (a.hasOwnProperty(i) !== b.hasOwnProperty(i)) return false;
17 if (!eqVal(a[i], b[i], recMap)) return false;
22 eqObj = function (a, b, recMap) {
23 var k1 = keys(a), k2 = keys(b);
24 if (k1.length !== k2.length) return false;
25 return k1.every(function (key) {
26 if (!propertyIsEnumerable.call(b, key)) return false;
27 return eqVal(a[key], b[key], recMap);
31 eqVal = function (a, b, recMap) {
33 if (eq(a, b)) return true;
34 if (isPlainObject(a)) {
35 if (!isPlainObject(b)) return false;
37 } else if (isArray(a) && isArray(b)) {
46 if (c2[i].indexOf(b) !== -1) return true;
52 return eqX(a, b, recMap);
55 module.exports = function (a, b) {
56 if (eq(value(a), value(b))) return true;
57 return eqVal(Object(a), Object(b), [[], []]);