diff --git a/src/util/visit.ts b/src/util/visit.ts index fcfc8de..9aafe3a 100644 --- a/src/util/visit.ts +++ b/src/util/visit.ts @@ -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( @@ -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") }