Skip to content

Commit

Permalink
fix index.neighbors freezing with just x/y args
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Apr 19, 2023
1 parent 41481c5 commit f3d24b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export default class Flatbush {
}
}

nodeIndex = q.pop() >> 1;
nodeIndex = q.length ? q.pop() >> 1 : undefined;
}

q.clear();
Expand Down
6 changes: 6 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ test('k-nearest-neighbors query accepts filterFn', () => {
assert.deepEqual(ids.sort(compare), [6, 16, 18, 24, 54, 80].sort(compare));
});

test('performs a k-nearest-neighbors query with all items', () => {
const index = createIndex();
const ids = index.neighbors(50, 50);
assert.deepEqual(ids.length, data.length >> 2);
});

test('returns index of newly-added rectangle', () => {
const count = 5;
const index = new Flatbush(count);
Expand Down

0 comments on commit f3d24b3

Please sign in to comment.