
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
k-nearest neighbors search for RBush. Implements a simple depth-first kNN search algorithm using a priority queue.
import RBush from 'rbush';
import knn from 'rbush-knn';
const tree = new RBush(); // create RBush tree
tree.load(data); // bulk insert
const neighbors = knn(tree, 40, 40, 10); // return 10 nearest items around point [40, 40]
You can optionally pass a filter function to find k neighbors that satisfy a certain condition:
const neighbors = knn(tree, 40, 40, 10, function (item) {
return item.foo === 'bar';
});
knn(tree, x, y, [k, filterFn, maxDistance])
tree: an RBush treex, y: query coordinatesk: number of neighbors to search for (Infinity by default)filterFn: optional filter function; k nearest items where filterFn(item) === true will be returned.maxDistance (optional): maximum distance between neighbors and the query coordinates (Infinity by default)FAQs
k-neareset neighbors search for RBush
The npm package rbush-knn receives a total of 10,916 weekly downloads. As such, rbush-knn popularity was classified as popular.
We found that rbush-knn demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.