blob: acdba73a2ff91932e9fc52e5bffe60a2a95dcab8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
---
title: WebAssembly.validate()
slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/validate
translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/validate
---
<div>{{JSRef}}</div>
<p><strong><code>WebAssembly.validate()</code> </strong>함수는 바이트가 유효한 wasm 모듈을 형성하는지 (<code>true</code>) 또는 생성하지 않는지 (<code>false</code>)를 반환하여 WebAssembly 바이너리 코드의 지정된 <a href="/ko/docs/Web/JavaScript/Typed_arrays">typed array</a>의 유효성을 검사합니다.</p>
<h2 id="Syntax">Syntax</h2>
<pre class="syntax">WebAssembly.validate(bufferSource);</pre>
<h3 id="Parameters">Parameters</h3>
<dl>
<dt><code><em>bufferSource</em></code></dt>
<dd>유효성을 검사 할 WebAssembly 바이너리 코드가 들어있는 <a href="/ko/docs/Web/JavaScript/Typed_arrays">typed array</a> 또는 <a href="/ko/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a>입니다.</dd>
</dl>
<h3 id="Return_value">Return value</h3>
<p><code>bufferSource</code>가 유효한 wasm 코드 (<code>true</code>)인지 아닌지 (<code>false</code>)를 지정하는 부울입니다.</p>
<h3 id="Exceptions">Exceptions</h3>
<p><code>bufferSource</code>가 <a href="/ko/docs/Web/JavaScript/Typed_arrays">typed array</a>이나 <a href="/ko/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a>가 아닌 경우 {{jsxref ( "TypeError")}}가 발생합니다.</p>
<h2 id="Examples">Examples</h2>
<p>다음 예제 (validate.html <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/validate.html">source code</a> 참조 및 <a href="https://mdn.github.io/webassembly-examples/js-api-examples/validate.html">see it live</a>)는 .wasm 모듈을 가져 와서 형식화 된 배열로 변환합니다. 그런 다음 <code>validate()</code> 메서드를 사용하여 모듈이 유효한지 확인합니다.</p>
<pre class="brush: js">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");
});
</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('WebAssembly JS', '#webassemblyvalidate', 'validate()')}}</td>
<td>{{Spec2('WebAssembly JS')}}</td>
<td>Initial draft definition.</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<div>
<p>{{Compat("javascript.builtins.WebAssembly.validate")}}</p>
</div>
<h2 id="See_also">See also</h2>
<ul>
<li><a href="/ko/docs/WebAssembly">WebAssembly</a> overview page</li>
<li><a href="/ko/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
<li><a href="/ko/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
</ul>
|