From 0631e99886e844624cc0a335de7a74773cbba9b2 Mon Sep 17 00:00:00 2001 From: Boris D Date: Thu, 9 Oct 2025 13:04:38 +0300 Subject: [PATCH] feat: simplify global function assignment in Vm class and enable logging of results in case1-payload test --- src/vm/vm.class.ts | 9 ++------- tests/base/case1-payload.js | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/vm/vm.class.ts b/src/vm/vm.class.ts index 26397a5..e5843f2 100644 --- a/src/vm/vm.class.ts +++ b/src/vm/vm.class.ts @@ -48,12 +48,7 @@ export class Vm { await this.context.evalClosure( ` - const name = $0; - const method = $1; - const ref = $2; - const ns = globalThis[name]; - - ns[method] = (...args) => ref.apply(undefined, args, { + globalThis[$0][$1] = (...args) => $2.apply(undefined, args, { arguments: { copy: true }, result: { promise: true, copy: true } }); @@ -85,7 +80,7 @@ export class Vm { }); this.setFunction("returnResult", (res) => { - // console.log("Returning result from VM:", res); + console.log("Returning result from VM:", res); resolvePromise(res); }); diff --git a/tests/base/case1-payload.js b/tests/base/case1-payload.js index c560a60..3eb2860 100644 --- a/tests/base/case1-payload.js +++ b/tests/base/case1-payload.js @@ -17,7 +17,7 @@ async function main(input, headers) { const res = await db.execute(sql); - // log(res); + log(res); return { response: {