Skip to content

Commit

Permalink
refactor(dcons): minor update equiv()
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Sep 19, 2020
1 parent cc13a8f commit 520fa76
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions packages/dcons/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,20 @@ export class DCons<T>

equiv(o: any) {
if (
(o instanceof DCons || isArrayLike(o)) &&
this._length === o.length
!(o instanceof DCons || isArrayLike(o)) ||
this._length !== o.length
) {
if (this._length === 0) {
return true;
}
let cell = this.head;
for (let x of <any>o) {
if (!equiv(cell!.value, x)) {
return false;
}
cell = cell!.next;
return false;
}
if (!this._length || this === o) return true;
let cell = this.head;
for (let x of <any>o) {
if (!equiv(cell!.value, x)) {
return false;
}
return true;
cell = cell!.next;
}
return false;
return true;
}

*[Symbol.iterator]() {
Expand Down

0 comments on commit 520fa76

Please sign in to comment.