I'm embedding a binary file within a WebAssembly wasm file.
Consider this source:
embed.ts (gets built to embed.wasm using AssemblyScript):
export const text: u8[] = [83,65,77,80,76,69,10]; // The text "SAMPLE" in UTF-8 encoding
export const textLength: i32 = text.length;
worker.js:
const instance = new WebAssembly.Instance(/* read embed.wasm */).exports;
instance.textLength // prints 7, correct
instance.text // prints, 10232 of type number, ?!?!?
How can I read out this byte array to enable reconstruction of the embedded file? I need to recreate the Uint8Array so in worker.js I can save the file or stream it somewhere.