@sebastianwessel/quickjs
Version:
A typescript package to execute JavaScript and TypeScript code in a WebAssembly QuickJS sandbox
19 lines (18 loc) • 609 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.call = void 0;
const call = (ctx, fileName, code, that, ...args) => {
const fnHandle = ctx.unwrapResult(ctx.evalCode(code, fileName));
try {
const callHandle = ctx.unwrapResult(ctx.callFunction(fnHandle, that || ctx.undefined, ...args));
fnHandle.dispose();
return callHandle;
}
catch (error) {
console.error(error);
const e = new Error(error.message ?? 'Function call failed in serialization');
e.cause = error;
throw e;
}
};
exports.call = call;