Skip to content

Commit 441004f

Browse files
committed
correctly set the removed node ref
1 parent 8b5e4f4 commit 441004f

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

packages/client/lib/client/linked-list.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,8 @@ export class DoublyLinkedList<T> {
2929
++this.#length;
3030

3131
if (this.#tail === undefined) {
32-
this.#head = {
32+
return this.#head = this.#tail = {
3333
previous: undefined,
34-
next: this.#tail,
35-
value
36-
};
37-
return this.#tail = {
38-
previous: this.#head,
3934
next: undefined,
4035
value
4136
};
@@ -92,15 +87,18 @@ export class DoublyLinkedList<T> {
9287

9388
if (this.#tail === node) {
9489
this.#tail = node.previous;
95-
}
96-
90+
}
9791
if (this.#head === node) {
9892
this.#head = node.next;
9993
} else {
100-
node.previous!.next = node.next;
101-
node.previous = undefined;
94+
if (node.previous) {
95+
node.previous.next = node.next;
96+
}
10297
}
103-
98+
if (node.next) {
99+
node.next.previous = node.previous;
100+
}
101+
node.previous = undefined;
104102
node.next = undefined;
105103
}
106104

0 commit comments

Comments
 (0)