The WebAssembly.promising() static method is used to wrap an exported Wasm function that relies on an asynchronous operation (that is, an imported suspending function created via the WebAssembly.Suspending() constructor), turning it into a Promise.
See WebAssembly.Suspending for an explanation of how this functionality works.
WebAssembly.promising(function)functionA reference to an exported Wasm function, typically available on the exports object available in the fulfilled value of a method such as WebAssembly.instantiateStreaming().
A function that wraps the original function passed into the promising() call, and can itself be called. The wrapper function takes the same arguments as the wrapped function, and returns a promise that fulfills with the wrapped function's results.
TypeErrorThe referenced function is not callable.
WebAssembly.instantiateStreaming(fetch("module.wasm"), { importObj }).then(
(result) => {
const fromWasm = WebAssembly.promising(
result.instance.exports.exportedFunc,
);
fromWasm().then((result) => {
// ...
});
},
);See WebAssembly.Suspending for a full working example.
WebAssembly.SuspendingWebAssembly.Suspending() constructor