This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

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

Syntax

var custSec = 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.

Example

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.

fetch('simple.wasm').then(response =>
  response.arrayBuffer()
).then(bytes =>
  WebAssembly.compile(bytes)
).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 Status Comment
Web Assembly JavaScript API
The definition of 'imports()' in that specification.
Draft Initial draft definition.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic Support5716522 No4411
FeatureAndroidChrome for AndroidEdge mobileFirefox for AndroidIE mobileOpera AndroidiOS Safari
Basic Support5757 (Yes)1522 No ?11

1. , this feature is behind the Experimental JavaScript Features preference.

2. Disabled in the Firefox 52 Extended Support Release (ESR).

See also

Document Tags and Contributors

 Contributors to this page: fscholz, syu_kato, chrisdavidmills, lukewagner, svodnik
 Last updated by: fscholz,