Uint32Array missing the function subarray()
I'm trying to work with a function which calls subarray on a Uint32Array object. This returns an error and it seems that the respective function is not implemented.
I've manage to work around the problem with slice, but it creates a copy rather than a pointer. Meaning it only works for me since I'm lucky enough to not have this call in conjunction with an assignment.
Yet it also means that I can't really automate the code and i have to keep a hard copy of the script. If it will change in the future on the server side, everything might break
You can use polyfills - they will contain implementation of Uint32Array in pure JS.
Thanks for the quick response. Could you please elaborate?
ctx = js2py.EvalJs()
js2py.require("babel-polyfill", context=ctx._context)
ctx.eval("let arr = new Uint32Array([0, 1, 2, 3, 4])")
ctx.eval("arr.slice(1, 2)")
ctx.eval("arr.subarray(1, 2)")
The polyfill adds Map, complete Uint32Array and other non JS5 features. However, it seems the subarray method for some reason does not work as expected (returns an empty array) even though it is now defined. Slice does work. Can you try patching this method manually?