Unable to use exported function from WebAssembly module?

Viewed 434

The following JavaScript code is throwing the error myMathModule.exports is 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 i = 0; i < 5; i++) {
            console.log(myMathModule.exports.doubleExp(i));
        }
    });
</script>

test.wasm exports the doubleExp function.

1 Answers
Related