Delaunator is an incredibly fast and robust JavaScript library designed for generating Delaunay triangulations of 2D points. Currently stable at version 5.1.0, it maintains an active release cadence, consistently delivering performance enhancements and numerical robustness. A key differentiator is its exceptional speed, validated through extensive benchmarks, and its ability to handle degenerate floating-point inputs reliably by integrating `robust-predicates`. It serves as a foundational component for other critical computational geometry libraries like `d3-delaunay` and `d3-geo-voronoi`, extending its utility to Voronoi diagrams and geographic applications. As of v5.0.0, it transitioned to ES Modules by default, necessitating Node.js v12+ environments, and v5.1.0 introduced first-class TypeScript types, making the separate `@types/delaunator` package obsolete.
npm install delaunatorVerified import paths — ran on the pinned version, not inferred.
This example initializes Delaunator with a flat array of coordinates and logs the resulting triangle, half-edge, and convex hull indices, demonstrating basic usage.
Use `import Delaunator from 'delaunator';` for ESM environments. For older Node.js or CommonJS projects, you might need to transpile your code or configure your bundler to handle ESM dependencies.
Configure your build tools (e.g., Babel) to transpile `node_modules/delaunator` if you need to support environments without modern JavaScript features.
Access convex hull points as an ordered array of indices, `delaunay.hull`, instead of attempting to traverse a linked list structure. Update any code that iterated through `hull` via `.next` properties.
Uninstall `@types/delaunator` from your project (`npm uninstall @types/delaunator` or `yarn remove @types/delaunator`). The types are now automatically included when you install `delaunator` itself.
Ensure you are using the correct input format for the method you choose. For `new Delaunator()`, provide a flat array or `Float64Array`. For `Delaunator.from()`, provide an array of point arrays, or customize with `getX` and `getY` accessors.
Change your import statement to `import Delaunator from 'delaunator';`. Ensure your project is set up to handle ES Modules, or use a bundler if targeting older environments.
For Node.js, add `"type": "module"` to your `package.json`. For browsers, use a bundler (like Webpack or Rollup) to transpile to a compatible format, or load via `<script type="module">` for modern browsers, or use the UMD build (`<script src="https://unpkg.com/delaunator/delaunator.min.js"></script>`).
Update your code to iterate over `delaunay.hull` as a `Uint32Array` of point indices instead of traversing a linked list. E.g., `for (const i of delaunay.hull) { /* ... */ }`.If using Delaunator < 5.1.0, install `@types/delaunator` (`npm install -D @types/delaunator`). If using v5.1.0+, ensure `@types/delaunator` is uninstalled and your `tsconfig.json` `moduleResolution` is set appropriately (e.g., `"node16"` or `"bundler"`).
No dependency data recorded yet.