The WebAssembly.imports()
function returns an array containing descriptions of all the declared imports of the given Module
.
The WebAssembly.imports()
function returns an array containing descriptions of all the declared imports of the given Module
.
WebAssembly.Module.imports(module)
module
A 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 compiles a loaded wasm module and queries the module's imports.
See imports.html source code and live version.
WebAssembly.compileStreaming(fetch('simple.wasm')) .then(function(mod) { const imports = WebAssembly.Module.imports(mod); console.log(imports[0]); });
The console log displays the following description for the imported module:
{ module: "imports", name: "imported_func", kind: "function" }
Desktop | Mobile | Server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | Deno | Node.js | |
imports |
57 |
16 |
52 |
No |
44 |
11 |
57 |
57 |
52 |
43 |
11 |
7.0 |
1.0 |
8.0.0 |
© 2005–2022 MDN 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