I have a u8[] array in WebAssembly code, how can I read it in regular JS? Calls to it just return me a i32.
// Load module WebAssembly.Instance
const instance = await getInstance("./build/embed.wasm");
// Try to get the array of bytes from the module
const embeddedFileBytes = Uint8Array.from(instance.fileBytes);
// write the file to disc
await writeFile("./output.text", embeddedFileBytes);
// check the hash is the same as the original file that was embedded
expect(sha1("./output.text")).toEqual(sha1("./input.text"))
The webassembly module has an export:
export const fileBytes: u8[] = [83,65,77,80,76,69,10];