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
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | Server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
imports | Chrome Full support 57 | Edge Full support 16 | Firefox
Full support
52
| IE No support No | Opera Full support 44 | Safari Full support 11 | WebView Android Full support 57 | Chrome Android Full support 57 | Firefox Android
Full support
52
| Opera Android Full support 43 | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.
- See implementation notes.