September 2018
Intermediate to advanced
328 pages
9h 10m
English
The Wasm files are instantiated in /src/load-assets.js. We're using the memory.wasm file from Cook the Books, but the /assets/main.wasm file is compiled from a slightly different version of main.c, which is located in the /lib folder. The loadWasm() function performs the same operation as the Wasm initialization code from Cook the Books, but the method for passing in the bufferSource to WebAssembly.instantiate() is different. Let's examine this further by reviewing a portion of the code in the loadWasm() function of the load-assets.js file:
const fs = require('fs');const path = require('path');const assetsPath = path.resolve(__dirname, 'assets');const getBufferSource = fileName => { const filePath ...Read now
Unlock full access