WebAssembly.Suspending() constructor
The WebAssembly.Suspending() constructor creates a new Suspending object instance representing a suspending function.
Syntax
js
new WebAssembly.Suspending(function)
Parameters
Return value
A new Suspending object instance.
Exceptions
WebAssembly.SuspendError-
The corresponding exported function was not wrapped in a
WebAssembly.promising()call. TypeError-
The referenced
functionis not callable.
Examples
>Basic usage
js
function someAsyncFunction() {
return fetch("https://example.com").then((result) => {
// ...
});
}
const importObj = {
someAsyncFunction: new WebAssembly.Suspending(someAsyncFunction),
};
See WebAssembly.Suspending for a full working example and explanation.
Specifications
| Specification |
|---|
| WebAssembly JavaScript Interface: Promise Integration> # dom-suspending-suspending> |