Skip to content

Commit

Permalink
refactor(geom): swap Group ctor & factory arg order
Browse files Browse the repository at this point in the history
- first attribs, then children...
  • Loading branch information
postspectacular committed Jan 28, 2019
1 parent af099ee commit 6d14f2b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions packages/geom/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ export class Group implements
children: IHiccupShape[];
attribs: Attribs;

constructor(children: IHiccupShape[], attribs?: Attribs) {
this.children = children;
constructor(attribs: Attribs, children?: IHiccupShape[]) {
this.attribs = attribs;
this.children = children || [];
}

get type() {
Expand All @@ -256,8 +256,8 @@ export class Group implements

copy() {
return new Group(
<IHiccupShape[]>this.children.map((c) => c.copy()),
{ ...this.attribs }
{ ...this.attribs },
<IHiccupShape[]>this.children.map((c) => c.copy())
);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/geom/src/ctors/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { Attribs, IHiccupShape } from "@thi.ng/geom-api";
import { Group } from "../api";

export const group =
(children: IHiccupShape[], attribs?: Attribs) =>
new Group(children, attribs);
(attribs: Attribs = {}, children?: IHiccupShape[]) =>
new Group(attribs, children);
4 changes: 2 additions & 2 deletions packages/geom/src/ops/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ transform.addAll({
[Type.GROUP]:
($: Group, mat) =>
new Group(
$.children.map((x) => <IHiccupShape>transform(x, mat)),
{ ...$.attribs }
{ ...$.attribs },
$.children.map((x) => <IHiccupShape>transform(x, mat))
),

[Type.LINE]: tx(Line),
Expand Down
4 changes: 2 additions & 2 deletions packages/geom/src/ops/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ translate.addAll({
[Type.GROUP]:
($: Group, delta) =>
new Group(
$.children.map((s) => <IHiccupShape>translate(s, delta)),
{ ...$.attribs }
{ ...$.attribs },
$.children.map((s) => <IHiccupShape>translate(s, delta))
),

[Type.LINE]: tx(Line),
Expand Down

0 comments on commit 6d14f2b

Please sign in to comment.