WebAssembly.validate()
function validates a given
typed array
of WebAssembly binary code, returning whether the bytes form a valid wasm module (
true
) or not (
false
).
WebAssembly.validate(bufferSource);
bufferSource
A boolean that specifies whether
bufferSource
is valid wasm code (
true
) or not (
false
).
若
bufferSource
is not a
typed array
or
ArrayBuffer
,
TypeError
is thrown.
The following example (see the validate.html
source code
,和
see it live too
) fetches a .wasm module and converts it into a typed array. The
validate()
method is then used to check whether the module is valid.
fetch('simple.wasm').then(response =>
response.arrayBuffer()
).then(function(bytes) {
var valid = WebAssembly.validate(bytes);
console.log("The given bytes are "
+ (valid ? "" : "not ") + "a valid wasm module");
});
| 规范 |
|---|
|
WebAssembly JavaScript 接口
The definition of 'validate()' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
validate
|
Chrome 57 | Edge 16 |
Firefox
52
|
IE No | Opera 44 | Safari 11 | WebView Android 57 | Chrome Android 57 |
Firefox Android
52
|
Opera Android 43 | Safari iOS 11 | Samsung Internet Android 7.0 | nodejs 8.0.0 |
完整支持
不支持
见实现注意事项。
WebAssembly
WebAssembly.Module
WebAssembly.Global
WebAssembly.Instance
WebAssembly.Memory
WebAssembly.Table
WebAssembly.CompileError
WebAssembly.LinkError
WebAssembly.RuntimeError
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()