Skip to content

Commit

Permalink
build(geom): expose internal helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jun 20, 2022
1 parent 8cdc372 commit 9babc6e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
9 changes: 9 additions & 0 deletions packages/geom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,15 @@
"./group": {
"default": "./group.js"
},
"./internal/copy": {
"default": "./internal/copy.js"
},
"./internal/dispatch": {
"default": "./internal/dispatch.js"
},
"./internal/transform": {
"default": "./internal/transform.js"
},
"./intersects": {
"default": "./intersects.js"
},
Expand Down
9 changes: 7 additions & 2 deletions packages/geom/src/internal/copy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// thing:export
import { copyVectors } from "@thi.ng/vectors/copy";
import type {
Attribs,
Expand All @@ -6,7 +7,11 @@ import type {
PCLikeConstructor,
} from "@thi.ng/geom-api";

/** @internal */
export const __copyAttribs = ($: IShape) => <Attribs>{ ...$.attribs };

export const __copyShape = (ctor: PCLikeConstructor, inst: PCLike) =>
new ctor(copyVectors(inst.points), __copyAttribs(inst));
/** @internal */
export const __copyShape = <T extends PCLike>(
ctor: PCLikeConstructor,
inst: T
) => <T>new ctor(copyVectors(inst.points), __copyAttribs(inst));
3 changes: 3 additions & 0 deletions packages/geom/src/internal/dispatch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// thing:export
import type { IShape } from "@thi.ng/geom-api";

/** @internal */
export const __dispatch = (x: IShape) => x.type;

/** @internal */
export const __dispatch2 = (a: IShape, b: IShape) => a.type + "-" + b.type;
1 change: 1 addition & 0 deletions packages/geom/src/internal/transform.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// thing:export
import type { Fn } from "@thi.ng/api";
import type { PCLike, PCLikeConstructor } from "@thi.ng/geom-api";
import type { MatOpMV, ReadonlyMat } from "@thi.ng/matrices";
Expand Down

0 comments on commit 9babc6e

Please sign in to comment.