Skip to content

Commit

Permalink
Ensure _chooseSplitIndex always return a number. Fix #69 (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoDoreto authored and mourner committed Jul 31, 2019
1 parent 4b11244 commit 15c31bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export default class RBush {
}
}

return index;
return index || M - m;
}

// sorts node children by the best axis for split
Expand Down
2 changes: 2 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ t('#insert handles the insertion of maxEntries + 2 empty bboxes', (t) => {

t.equal(tree.toJSON().height, 2);
sortedEqual(t, tree.all(), emptyData);
t.equal(tree.data.children[0].children.length, 4);
t.equal(tree.data.children[1].children.length, 2);

t.end();
});
Expand Down

0 comments on commit 15c31bd

Please sign in to comment.