The WebAssembly.imports()
function returns an array containing descriptions of all the declared imports of the given Module
.
var custSec = WebAssembly.Module.imports(module);
WebAssembly.Module
object.An array containing objects representing the imported functions of the given module.
If module is not a WebAssembly.Module
object instance, a TypeError
is thrown.
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" }
Specification | Status | Comment |
---|---|---|
WebAssembly JavaScript API The definition of 'imports()' in that specification. | Draft | Initial draft definition. |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 57 | 16 | 522 | No | 44 | 11 |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | 57 | 57 | Yes1 | 522 | No | ? | 11 |
1. This feature is behind the Experimental JavaScript Features
preference.
2. Disabled in the Firefox 52 Extended Support Release (ESR).
© 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