refactor: simplify async function calls in asyncCall and Vm class

This commit is contained in:
Boris D
2025-09-22 18:38:21 +03:00
parent fbbbd61838
commit 07efa3b8df
2 changed files with 7 additions and 5 deletions

View File

@ -4,9 +4,13 @@ async function asyncCall(reference, args) {
args = [args];
}
const resJson = await reference.apply(undefined, args, {
const res = await reference.apply(undefined, args, {
result: { promise: true },
});
return JSON.parse(resJson);
if (typeof res === "string") {
return JSON.parse(res);
}
return res;
}

View File

@ -35,9 +35,7 @@ export class Vm {
this.jail.setSync(
plugin.getName(),
new ivm.Reference(async (...args) => {
const res = await plugin.run(...args);
return res;
return await plugin.run(...args);
})
);
}