mapbox / delaunator

An incredibly fast JavaScript library for Delaunay triangulation of 2D points
https://mapbox.github.io/delaunator/
ISC License
2.33k stars 142 forks source link

Allow plain arrays. #20

Closed mbostock closed 6 years ago

mbostock commented 6 years ago

Would you consider relaxing this requirement? šŸ˜

Certainly itā€™s good to encourage the use of a typed array here, say through documentation and examples, but I donā€™t anticipate the implementation would require that is the input is a typed array (e.g., I donā€™t think weā€™d need to call coords.subarray). So it seems reasonable to allow anything array-like as input.

In particular, itā€™s nice if you already have a flat plain array [x0, y0, x1, y1, ā€¦] from some other library, and you arenā€™t forced to copy that array into a Float64Array to compute the Delaunay triangulation.

mbostock commented 6 years ago

Excellent. Iā€™ve added the requested check.