WebAssembly.Module.imports()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2017.
WebAssembly.imports()
関数は、指定された Module
の全てのインポート宣言の定義を配列として返します。
構文
js
WebAssembly.Module.imports(module);
引数
- module
-
WebAssembly.Module
オブジェクトです。
返値
指定されたモジュールのインポートされた関数を表現するオブジェクトの配列。
例外
module が WebAssembly.Module
オブジェクトインスタンスでなかった場合は、 TypeError
が発生します。
例
imports の使用
次の例では (imports.html と動作例も参照)、読み込んだ simple.wasm モジュールをコンパイルします。このモジュールは imports から問い合わせされます。
js
WebAssembly.compileStreaming(fetch("simple.wasm")).then(function (mod) {
var imports = WebAssembly.Module.imports(mod);
console.log(imports[0]);
});
出力はこのようになります。
js
{ module: "imports", name: "imported_func", kind: "function" }
仕様書
Specification |
---|
WebAssembly JavaScript Interface # dom-module-imports |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
imports() static method |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
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.