Passing Strings and Arrays between JS and WASM

WASM has a linear memory to pass data between JavaScript (or any other hosting environment) and WASM. Any data which cannot be represented by WASMs data types (32 and 64bit integers and floats) also has to be passed through this memory. In JavaScript we can access the WASM memory through a DataView object. WebAssembly.instantiateStreaming(fetch("lib.wasm"), {}).then( (obj) => { const dv = new…