Callbacks
A function pointer parameter takes a JavaScript function, and C++ calls it like any other.
countdown calls its Visitor once for every number, and each call runs the arrow function from main.js. applyTwice uses what its Transform returns.
A module has 64 callback slots. Each function handed to C++ holds one until m.releaseCallback(fn) frees it: the same function passed again keeps its slot, while a new arrow function takes another. So release a function once C++ no longer needs it.
A function cannot cross into a Web Worker, so a browser app that passes callbacks runs its module on the page thread, with initNative({ useWorker: false }).
Try it
Pass applyTwice a function that squares its argument and check the result.