The `kd-tree-javascript` library provides a basic but high-performance JavaScript implementation of the k-dimensional tree data structure. It's designed for organizing points in k-dimensional space, facilitating efficient range searches and nearest neighbor queries. Currently at version 1.0.3, the library uses a UMD (Universal Module Definition) pattern, allowing it to be used in browser environments (exposing global variables `kdTree` and `BinaryHeap`) and with module loaders like RequireJS. Its primary differentiator was its reported speed and simplicity for specific spatial data operations, as highlighted by various demos. Due to its last update being in 2017, the library is considered abandoned, meaning no further feature development, bug fixes, or security patches are expected.
npm install kd-tree-javascriptVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a k-d tree, insert points, define a distance function, and perform a nearest neighbor search.
Consider explicitly removing global variables if conflicts arise, or encapsulate usage within a self-executing function if not using a module loader.
Evaluate alternatives if long-term support, active maintenance, or modern JavaScript features are required. Use with caution in new projects.
Periodically check the `balanceFactor()` of the tree. If performance is critical and the balance factor is high, rebuild the tree from scratch with existing points to restore balance.
Ensure the `kdTree.js` file is correctly linked in your HTML before other scripts using it, or use `require()` with the correct module path in a CommonJS environment.
For CommonJS, use `const ubilabs = require('kd-tree-javascript');` and then `new ubilabs.kdTree(...)`. For RequireJS, ensure the module path is correct and the callback argument (e.g., `ubilabs`) is used as shown in the documentation.No dependency data recorded yet.