Is there a more efficient way to return arrays from C++ to javascript?
问题 To pass typed array from emscripten'ed C++ to javascript I came up with this code #include <emscripten/bind.h> #include <emscripten/val.h> auto test(const emscripten::val &input) { const auto data = emscripten::convertJSArrayToNumberVector<float>(input); // copies data // generate output in some form std::vector<float> output = { 1, 2, 3 }; // make a typed array view of the output emscripten::val view{ emscripten::typed_memory_view(output.size(), output.data()) }; // create new typed array to