AK-21/Graphite-Industrial-Intelligence
0
1var has = Object.prototype.hasOwnProperty;2 3export function dequal(foo, bar) {4 var ctor, len;5 if (foo === bar) return true;6 7 if (foo && bar && (ctor=foo.constructor) === bar.constructor) {8 if (ctor === Date) return foo.getTime() === bar.getTime();9 if (ctor === RegExp) return foo.toString() === bar.toString();10 11 if (ctor === Array) {12 if ((len=foo.length) === bar.length) {13 while (len-- && dequal(foo[len], bar[len]));14 }15 return len === -1;16 }17 18 if (!ctor || typeof foo === 'object') {19 len = 0;20 for (ctor in foo) {21 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;22 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;23 }24 return Object.keys(bar).length === len;25 }26 }27 28 return foo !== foo && bar !== bar;29}30 