use super::*;
pub fn validate(bytes: &Any) -> bool {
Any::global("WebAssembly")
.call("validate", &[bytes.into()])
.as_::<bool>()
}
pub fn compile(bytes: &Any) -> Promise<Module> {
Any::global("WebAssembly")
.call("compile", &[bytes.into()])
.as_::<Promise<Module>>()
}
pub fn instantiate(module_object: &Module) -> Promise<Instance> {
Any::global("WebAssembly")
.call("instantiate", &[module_object.into()])
.as_::<Promise<Instance>>()
}
pub fn instantiate_with_import_object(
module_object: &Module,
import_object: &Object,
) -> Promise<Instance> {
Any::global("WebAssembly")
.call("instantiate", &[module_object.into(), import_object.into()])
.as_::<Promise<Instance>>()
}
pub fn compile_streaming(source: &Promise<Response>) -> Promise<Module> {
Any::global("WebAssembly")
.call("compileStreaming", &[source.into()])
.as_::<Promise<Module>>()
}
pub fn instantiate_streaming(source: &Promise<Response>) -> Promise<WebAssemblyInstantiatedSource> {
Any::global("WebAssembly")
.call("instantiateStreaming", &[source.into()])
.as_::<Promise<WebAssemblyInstantiatedSource>>()
}
pub fn instantiate_streaming_with_import_object(
source: &Promise<Response>,
import_object: &Object,
) -> Promise<WebAssemblyInstantiatedSource> {
Any::global("WebAssembly")
.call(
"instantiateStreaming",
&[source.into(), import_object.into()],
)
.as_::<Promise<WebAssemblyInstantiatedSource>>()
}