Skip to content

Commit

Permalink
import module logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Mar 7, 2019
1 parent f2ff3d3 commit cbc3499
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default function dequal(foo, bar) {
var ctor, len;
if (foo === bar) return true;
if (foo && bar && (ctor=foo.constructor) === bar.constructor) {
if (ctor === Date) return foo.getTime() === bar.getTime();
if (ctor === RegExp) return foo.toString() === bar.toString();
if (ctor === Array && (len=foo.length) === bar.length) {
while (len-- && dequal(foo[len], bar[len]));
return len === -1;
}
if (ctor === Object) {
if (Object.keys(foo).length !== Object.keys(bar).length) return false;
for (len in foo) if (!(len in bar) || !dequal(foo[len], bar[len])) return false;
return true;
}
}
return foo !== foo && bar !== bar;
}

0 comments on commit cbc3499

Please sign in to comment.