Skip to content

Commit

Permalink
refactor(iges): update defmulti impls
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Sep 29, 2021
1 parent 0188d23 commit b7c0abe
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/iges/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,18 @@ export const newDocument = (
): IGESDocument => {
const globals = <GlobalParams>{ ...DEFAULT_GLOBALS, ...g };
const $FF = float(globals.precision);
const $PARAM = defmulti<any[], string>((x) => x[1]);
$PARAM.add(Type.INT, (x) => x[0].toString());
$PARAM.add(Type.POINTER, (x) => (-x[0]).toString());
$PARAM.add(Type.FLOAT, (x) => $FF(x[0]));
$PARAM.add(Type.STR, (x) => x[0]);
$PARAM.add(Type.HSTR, (x) => hstr(x[0]));
$PARAM.add(Type.DATE, (x) => $DATE(x[0]));
const $PARAM = defmulti<any[], string>(
(x) => x[1],
{},
{
[Type.INT]: (x) => x[0].toString(),
[Type.POINTER]: (x) => (-x[0]).toString(),
[Type.FLOAT]: (x) => $FF(x[0]),
[Type.STR]: (x) => x[0],
[Type.HSTR]: (x) => hstr(x[0]),
[Type.DATE]: (x) => $DATE(x[0]),
}
);

return {
globals,
Expand Down

0 comments on commit b7c0abe

Please sign in to comment.