// [SMDOC] JS Promise Integration // // The API provides relatively efficient and relatively ergonomic interop // between JavaScript promises and WebAssembly but works under the constraint // that the only changes are to the JS API and not to the core wasm. // // Here is a small example that uses JS Promise Integration API: // // const suspending = new WebAssembly.Suspending(async () => 42) // const ins = wasmTextEval(`(module // (import "" "suspending" (func $imp (result i32))) // (func (export "entry") (result i32) (call $imp)) // )`, {"": { suspending, }}) // const promising = WebAssembly.promising(ins.exports.entry) // assertEq(await promising(), 42) // // The `new WebAssembly.Suspending(fn)` logic is implemented in a Wasm module // generated by `SuspendingFunctionModuleFactory` utility (see WasmPI.cpp). // The `WebAssembly.promising(wasmfn)` logic is implemented in a Wasm module // generated by `PromisingFunctionModuleFactory` utility. // // See [SMDOC] Wasm Stack Switching in WasmStacks.cpp for the underlying // continuation stack machinery that this API is built on.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.