Skip to content

Commit 6cf4715

Browse files
schurhammerlpil
authored andcommitted
fix bug in persistent-hash-map.mjs
missing check for key equality in the find function
1 parent 3d40ff8 commit 6cf4715

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/persistent-hash-map.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,13 @@ function findArray(root, shift, hash, key) {
581581
if (node === undefined) {
582582
return undefined;
583583
}
584-
if (node.type === ENTRY) {
584+
if (node.type !== ENTRY) {
585+
return find(node, shift + SHIFT, hash, key);
586+
}
587+
if (isEqual(key, node.k)) {
585588
return node;
586589
}
587-
return find(node, shift + SHIFT, hash, key);
590+
return undefined;
588591
}
589592
/**
590593
* @template K,V

0 commit comments

Comments
 (0)