From c327a1dfc40b834b31c3488020859223f3583b4c Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 13 Aug 2023 15:34:18 +0530 Subject: feat: adds add-children and remove-element actions --- src/eval.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/eval.ts') diff --git a/src/eval.ts b/src/eval.ts index 3a4e4f9..3d6734f 100644 --- a/src/eval.ts +++ b/src/eval.ts @@ -25,6 +25,8 @@ export interface EvalActions { url: string data: FormData | undefined }): Promise + addChildren(id: string, children: Expr[]): Promise + removeElement(id: string | undefined): Promise // calculate ?? } @@ -126,6 +128,15 @@ const getFunctions = (name: string, args: Expr[], actions: EvalActions) => } }, + 'add-children': async () => { + const id = await evalExpr(args[0], actions) + if (id) actions.addChildren(id, args.slice(1)) + }, + 'remove-element': async () => + actions.removeElement( + (args[0] && (await evalExpr(args[0], actions))) ?? undefined, + ), + _: () => Promise.reject(new Error('not supposed to be here')), }) -- cgit v1.3.1