From 6a889de8c4b7015c825a4026756feb68c3bf81f1 Mon Sep 17 00:00:00 2001 From: Gnlow Date: Wed, 20 Dec 2023 12:37:43 +0900 Subject: [PATCH] refactor: split getInitData --- src/util/visit.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) 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") }