WebAssembly.Module()
构造函数可以用来同步编译给定的 WebAssembly 二进制代码。不过,获取 Module
对象的主要方法是通过异步编译函数,如 WebAssembly.compile()
,或者是通过 IndexedDB 读取 Module 对象.重要提示:由于大型模块的编译可能很消耗资源,开发人员只有在绝对需要同步编译时,才使用 Module()
构造函数;其他情况下,应该使用异步 WebAssembly.compile()
方法。
var myModule = new WebAssembly.Module(bufferSource);
Module
构造函数的方法属性WebAssembly.Module.customSections()
Module
对象和字符串,通过该字符串,返回 Module 对象中所有自定义部分的内容的副本。WebAssembly.Module.exports()
Module
对象,返回一个数组,内容是所有已声明的接口的描述。WebAssembly.Module.imports()
Module
对象,返回一个数组,内容是所有已声明的引用的描述。Module
实例所有 Module
实例继承自 Module()
构造函数的原型对象 —— 修改它会影响所有 Module
实例。
Module.prototype.constructor
WebAssembly.Module()
constructor.Module.prototype[@@toStringTag]
Module 实例没有自己的默认方法。
规范 | 状态 | 注释 |
---|---|---|
WebAssembly JavaScript Interface WebAssembly.Module() |
Working Draft | 定义初稿 |
Desktop | Mobile | Server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Module | 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 | Edge Mobile
Full support
Yes
| Firefox Android
Full support
52
| Opera Android ? | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
customSections | 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 | Edge Mobile
Full support
Yes
| Firefox Android
Full support
52
| Opera Android ? | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
exports | 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 | Edge Mobile
Full support
Yes
| Firefox Android
Full support
52
| Opera Android ? | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
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 | Edge Mobile
Full support
Yes
| Firefox Android
Full support
52
| Opera Android ? | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |
prototype | 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 | Edge Mobile
Full support
Yes
| Firefox Android
Full support
52
| Opera Android ? | Safari iOS Full support 11 | Samsung Internet Android Full support 7.0 | nodejs Full support 8.0.0 |