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];
|
args = [args];
|
||||||
}
|
}
|
||||||
|
|
||||||
const resJson = await reference.apply(undefined, args, {
|
const res = await reference.apply(undefined, args, {
|
||||||
result: { promise: true },
|
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(
|
this.jail.setSync(
|
||||||
plugin.getName(),
|
plugin.getName(),
|
||||||
new ivm.Reference(async (...args) => {
|
new ivm.Reference(async (...args) => {
|
||||||
const res = await plugin.run(...args);
|
return await plugin.run(...args);
|
||||||
|
|
||||||
return res;
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user