Skip to content

Commit

Permalink
feat(geom): add internal __ensurePCLike() helper
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jun 11, 2024
1 parent bf91ff3 commit 7306b35
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/geom/src/internal/pclike.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
// thing:export
import { isArray } from "@thi.ng/checks/is-array";
import { assert } from "@thi.ng/errors/assert";
import type { PCLikeConstructor } from "../api.js";
import type { IShape, PCLike, PCLikeConstructor } from "../api.js";
import { __argAttribs } from "./args.js";

export const __ensurePCLike = (x: IShape): PCLike => {
assert(isArray((<any>x).points), "expected a PCLike shape");
return <PCLike>x;
};

export const __pclike = (ctor: PCLikeConstructor, args: any[]) => {
const attr = __argAttribs(args);
return new ctor(args.length === 1 ? args[0] : args, attr);
Expand Down

0 comments on commit 7306b35

Please sign in to comment.