Skip to content

Commit

Permalink
fix: don't use array length as precondition
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Jul 15, 2020
1 parent fd3d291 commit 4d76378
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ export default function dequal(foo, bar) {
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) {

if (ctor === Array) {
if ((len=foo.length) === bar.length) {
while (len-- && dequal(foo[len], bar[len]));
}
return len === -1;
}
if (ctor === Object) {
Expand Down

0 comments on commit 4d76378

Please sign in to comment.