Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing ModuleEvalOptions to evalCode #38

Open
tim-field opened this issue Jul 8, 2024 · 1 comment
Open

passing ModuleEvalOptions to evalCode #38

tim-field opened this issue Jul 8, 2024 · 1 comment

Comments

@tim-field
Copy link

quickjs-emscripten supports a second options param to evalCode of type ModuleEvalOptions

https://github.com/justjake/quickjs-emscripten/tree/main?tab=readme-ov-file#safely-evaluate-javascript-code

https://github.com/justjake/quickjs-emscripten/blob/main/doc/quickjs-emscripten/classes/QuickJSWASMModule.md#evalcode

Is there a way to specify these options when using quickjs-emscripten-sync ?

@digipigeon
Copy link

It looks like it would be pretty easy to add this as an extra param. Not sure if there would be any side effects anywhere else.

/**
* Evaluate JS code in the VM and get the result as an object on the host side. It also converts and re-throws error objects when an error is thrown during evaluation.
*/
evalCode<T = any>(code: string): T {
const handle = this.context.evalCode(code);
return this._unwrapResultAndUnmarshal(handle);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants