WebAssembly.Module.imports()

The WebAssembly.imports() function returns an array containing descriptions of all the declared imports of the given Module.

Syntax

WebAssembly.Module.imports(module)

Parameters

module

A WebAssembly.Module object.

Return value

An array containing objects representing the imported functions of the given module.

Exceptions

If module is not a WebAssembly.Module object instance, a TypeError is thrown.

Examples

Using imports

The following example compiles a loaded wasm module and queries the module's imports.

See imports.html source code and live version.

WebAssembly.compileStreaming(fetch('simple.wasm'))
.then(function(mod) {
  const imports = WebAssembly.Module.imports(mod);
  console.log(imports[0]);
});

The console log displays the following description for the imported module:

{ module: "imports", name: "imported_func", kind: "function" }

Specifications

Specification
WebAssembly JavaScript Interface: Exception Handling
# dom-module-imports

Browser compatibility

BCD tables only load in the browser

See also