finds.dev← search

// the find

mourner/rbush

★ 2,759 · JavaScript · MIT · updated Jul 2026

RBush — a high-performance JavaScript R-tree-based 2D spatial index for points and rectangles

RBush is a mature JavaScript R-tree implementation for 2D spatial queries — bounding box searches, collision detection, nearest-neighbor prep. It's the right tool when you need to ask 'what's in this area?' over large sets of points or rectangles without burning through a full scan every time. Vlad Agafonkin (Leaflet author) built it, which shows in the quality.

The bulk-load path is genuinely fast — OMT algorithm with Floyd-Rivest selection means initial indexing of 1M items in ~1.25s is not marketing fluff, it's documented and reproducible. The algorithms section cites actual papers with links, so you can verify the implementation choices yourself. JSON export/import is well-thought-out: index on the server, ship the pre-built tree to the client, no re-indexing cost. The custom data format override via subclassing is clean — no adapter layer needed if your objects aren't minX/minY shaped.

Performance benchmarks are from Node.js v6.2.2 on a 2012 MacBook Pro — those numbers are over a decade old and tell you nothing about current V8 or modern hardware. The pure-ESM move (v4+) drops CommonJS support entirely, which will bite anyone on an older bundler or non-module environment who doesn't notice the footnote. No 3D or higher-dimensional support — if your use case grows beyond 2D you're starting over. Deletion performance degrades somewhat by design (underflowed nodes stay in the tree until empty) and the README is honest about this trade-off, but it can surprise you if you're doing high-frequency remove/reinsert cycles.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →