Skip to content

Commit 778acc9

Browse files
mbostockmourner
authored andcommitted
Static from.
1 parent 75edf35 commit 778acc9

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/delaunay.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ function jitter(x, y, r) {
3131
return [x + Math.sin(x + y) * r, y + Math.cos(x - y) * r];
3232
}
3333

34-
export default Object.assign(class Delaunay {
34+
export default class Delaunay {
35+
static from(points, fx = pointX, fy = pointY, that) {
36+
return new Delaunay("length" in points
37+
? flatArray(points, fx, fy, that)
38+
: Float64Array.from(flatIterable(points, fx, fy, that)));
39+
}
3540
constructor(points) {
3641
this._delaunator = new Delaunator(points);
3742
this.inedges = new Int32Array(points.length / 2);
@@ -216,13 +221,7 @@ export default Object.assign(class Delaunay {
216221
this.renderTriangle(i, polygon);
217222
return polygon.value();
218223
}
219-
}, {
220-
from(points, fx = pointX, fy = pointY, that) {
221-
return new Delaunay("length" in points
222-
? flatArray(points, fx, fy, that)
223-
: Float64Array.from(flatIterable(points, fx, fy, that)));
224-
}
225-
});
224+
}
226225

227226
function flatArray(points, fx, fy, that) {
228227
const n = points.length;

0 commit comments

Comments
 (0)