Skip to content

Commit 8355f56

Browse files
authored
Fix nullish comparison to handle null values, refs #17 (#28)
1 parent 8e6e2b6 commit 8355f56

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

resources/indexes/HierarchicalNavigableSmallWorld.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class HierarchicalNavigableSmallWorld {
107107
} else oldNode = {} as Node;
108108
if (vector) {
109109
let entryPoint = entryPointId && this.indexStore.get(entryPointId);
110-
if (entryPoint === undefined) {
110+
if (entryPoint == null) {
111111
const level = Math.floor(-Math.log(Math.random()) * this.mL);
112112
const node = {
113113
vector,
@@ -305,7 +305,7 @@ export class HierarchicalNavigableSmallWorld {
305305
}
306306
function updateNode(id: number, node?: Node) {
307307
// keep a record of all our changes, maintaining any changes that are queued to be written
308-
let updatedNode: Node = updatedNodes.get(id)!;
308+
let updatedNode: Node = updatedNodes.get(id);
309309
if (!updatedNode && node) {
310310
// copy the node so we can modify it
311311
updatedNode = { ...node };
@@ -363,7 +363,7 @@ export class HierarchicalNavigableSmallWorld {
363363
while (candidates.length > 0) {
364364
// Get closest unvisited element
365365
candidates.sort((a, b) => a.distance - b.distance);
366-
const current = candidates.shift()!;
366+
const current = candidates.shift();
367367

368368
// Get least result distance
369369
const furthestDistance = results[results.length - 1].distance;

0 commit comments

Comments
 (0)