refactor: simplify async function calls in asyncCall and Vm class
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user