Skip to content

Commit

Permalink
refactor: split getInitData
Browse files Browse the repository at this point in the history
  • Loading branch information
gnlow committed Dec 20, 2023
1 parent 6e12922 commit 6a889de
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/util/visit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ export class Visitor {
return [
cg.call(
"init" as Expression,
[JSON5.stringify({
...project,
objects: project.objects.map(
({script: _, ...rest}) => rest
),
functions: project.functions.map(
({content: _, ...rest}) => rest
),
}) as Expression]
[JSON5.stringify(this.getInitData(project)) as Expression]
),
"",
project.functions.map(
Expand All @@ -42,6 +34,18 @@ export class Visitor {
].join("\n")
}

getInitData(project: Project) {
return {
...project,
objects: project.objects.map(
({script: _, ...rest}) => rest
),
functions: project.functions.map(
({content: _, ...rest}) => rest
),
}
}

visitObject(object: Object_) {
return this.objectToExpressions(object).join("\n")
}
Expand Down

0 comments on commit 6a889de

Please sign in to comment.