WebAssembly.validate()
함수는 바이트가 유효한 wasm 모듈을 형성하는지 (true
) 또는 생성하지 않는지 (false
)를 반환하여 WebAssembly 바이너리 코드의 지정된 typed array의 유효성을 검사합니다.
Syntax
WebAssembly.validate(bufferSource);
Parameters
bufferSource
- 유효성을 검사 할 WebAssembly 바이너리 코드가 들어있는 typed array 또는 ArrayBuffer입니다.
Return value
bufferSource
가 유효한 wasm 코드 (true
)인지 아닌지 (false
)를 지정하는 부울입니다.
Exceptions
bufferSource
가 typed array이나 ArrayBuffer가 아닌 경우 TypeError
가 발생합니다.
Examples
다음 예제 (validate.html source code 참조 및 see it live)는 .wasm 모듈을 가져 와서 형식화 된 배열로 변환합니다. 그런 다음 validate()
메서드를 사용하여 모듈이 유효한지 확인합니다.
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"); });
Specifications
Specification | Status | Comment |
---|---|---|
WebAssembly JavaScript Interface The definition of 'validate()' in that specification. |
Working Draft | Initial draft definition. |
Browser compatibility
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.
Update compatibility data on GitHub
Desktop | Mobile | Server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
validate | 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 | 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 |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- See implementation notes.
- See implementation notes.