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

句法

WebAssembly.Module.imports(module);
					

参数

module
WebAssembly.Module 对象。

返回值

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.

范例

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]);
});
					

输出看起来像这样:

{ module: "imports", name: "imported_func", kind: "function" }
					

规范

规范
WebAssembly JavaScript 接口
The definition of 'imports()' in that specification.

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet Node.js
imports Chrome 57 Edge 16 Firefox 52
52
Disabled in the Firefox 52 Extended Support Release (ESR).
IE No Opera 44 Safari 11 WebView Android 57 Chrome Android 57 Firefox Android 52
52
Disabled in the Firefox 52 Extended Support Release (ESR).
Opera Android 43 Safari iOS 11 Samsung Internet Android 7.0 nodejs 8.0.0

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

另请参阅

元数据

  • 最后修改: