You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having troubles with passing array buffer.
I followed the first example in the readme, but with additional code to handle array buffer.
And then tried doing some modifications, but... every time the results are mostly undefined...
That leads me to conclusion that I must be doing something wrong (very likely) or there may be an implementation issue?
Following code
import{getQuickJS}from"quickjs-emscripten"asyncfunctionmain(){constQuickJS=awaitgetQuickJS()constvm=QuickJS.newContext()constworld=vm.newString("ArrayBuffer")constab=newUint8Array([1,1])console.log(ab[0],ab.length)constones=vm.newArrayBuffer(ab);vm.setProp(vm.global,"NAME",world)vm.setProp(vm.global,'ones',ones)world.dispose()ones.dispose()constresult=vm.evalCode(`"Hello " + NAME + ", why are you " + ones.length + "?"`)if(result.error){console.log("Execution failed:",vm.dump(result.error))result.error.dispose()}else{console.log("Success:",vm.dump(result.value))result.value.dispose()}vm.dispose()}main().then(r=>console.log('Finished'));
produces following result
1 2
Success: Hello ArrayBuffer, why are you undefined?
Finished
Hi, I'm also seeing the same thing. When I log the length of the arraybuffer created using vm.newArrayBuffer, it shows as undefined in the output of vm.evalCode.
It can be easily recreated in the browser like so:
Activity
flawiddsouza commentedon Apr 20, 2024
Hi, I'm also seeing the same thing. When I log the length of the arraybuffer created using vm.newArrayBuffer, it shows as undefined in the output of vm.evalCode.
It can be easily recreated in the browser like so:
Output: