Unable to use exported function from WebAssembly module? -


the following javascript code throwing error mymathmodule.exports undefined:

<script> fetch("test.wasm")     .then(function(response) {         return response.arraybuffer();     })     .then(function(buffer) {         var modulebufferview = new uint8array(buffer);         var mymathmodule = webassembly.instantiate(modulebufferview);           for(var = 0; < 5; i++) {             console.log(mymathmodule.exports.doubleexp(i));         }     }); </script> 

test.wasm exports doubleexp function.

webassembly.instantiate promise. you're trying use webassembly.instance promise returns when completes. like

fetch("test.wasm") .then(function(response) {     return response.arraybuffer(); }) .then(function(buffer) {     var modulebufferview = new uint8array(buffer);     webassembly.instantiate(modulebufferview)     .then(function(instantiated) {         const instance = instantiated.instance;         console.log(instance.exports.doubleexp(i));     }) }); 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -