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 (see imports.html source code; see it live also) compiles the loaded simple.wasm module. This module is then queried for its imports.

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

The output looks like this:

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

Specifications

Specification
WebAssembly JavaScript Interface
The definition of 'imports()' in that specification.

Browser compatibility

DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
importsChrome Full support 57Edge Full support 16Firefox Full support 52
Notes
Full support 52
Notes
Notes Disabled in the Firefox 52 Extended Support Release (ESR).
IE No support NoOpera Full support 44Safari Full support 11WebView Android Full support 57Chrome Android Full support 57Firefox Android Full support 52
Notes
Full support 52
Notes
Notes Disabled in the Firefox 52 Extended Support Release (ESR).
Opera Android Full support 43Safari iOS Full support 11Samsung Internet Android Full support 7.0nodejs Full support 8.0.0

Legend

Full support
Full support
No support
No support
See implementation notes.
See implementation notes.

See also