我在 WebAssembly 代码中有一个 u8[] 数组,如何在常规 JS 中读取它?调用它只是给我一个 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"))
webassembly 模块有一个导出:
export const fileBytes: u8[] = [83,65,77,80,76,69,10];