W3cubDocs

/JavaScript

WebAssembly.module.imports

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.

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 Status Comment
WebAssembly JavaScript Interface
The definition of 'imports()' in that specification.
Working Draft Initial draft definition.

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 57 16 52
52
Disabled in the Firefox 52 Extended Support Release (ESR).
No 44 11
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support 57 57 Yes
Disabled
Yes
Disabled
Disabled This feature is behind the Experimental JavaScript Features preference.
52
52
Disabled in the Firefox 52 Extended Support Release (ESR).
? 11 7.0
Server
Node.js
Basic support 8.0.0

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module/imports