fromModuleAsync static method
Asynchronously instantiates compiled WebAssembly Module with imports.
See Instance.fromModule regarding importMap
and importObject
usage.
Implementation
static Future<Instance> fromModuleAsync(
Module module, {
Map<String, Map<String, Object>>? importMap,
Object? importObject,
}) =>
promiseToFuture<_Instance>(
_instantiateModule(
module.jsObject,
_reifyImports(importMap, importObject),
),
).then((instance) => Instance._(instance, module)).catchError((Object e) {
if (instanceof(e, _compileError)) {
throw CompileError(getProperty(e, 'message'));
} else if (instanceof(e, _linkError)) {
throw LinkError(getProperty(e, 'message'));
} else if (instanceof(e, _runtimeError)) {
throw RuntimeError(getProperty(e, 'message'));
}
// ignore: only_throw_errors
throw e;
});