aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html
blob: 13cbbdeef40a64f673dd275b57d62d4579e36706 (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
76
77
78
79
80
81
82
83
84
85
86
87
---
title: WebAssembly.compileStreaming()
slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming
tags:
  - API
  - JavaScript
  - Method
  - Object
  - Reference
  - WebAssembly
  - compile
  - compileStreaming
  - streaming
translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming
---
<div>{{JSRef}}</div>

<p>Die <strong><code>WebAssembly.compileStreaming()</code></strong> Funktion kompiliert ein {{jsxref("WebAssembly.Module")}} direkt aus einer zugrunde liegenden Quelle. Nützlich ist diese Funktion wenn ein Modul kompiliert werden muss, bevor es instanziiert werden kann. (ansonsten sollte die {{jsxref("WebAssembly.instantiateStreaming()")}} Funktion verwendet werden).</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">Promise&lt;WebAssembly.Module&gt; WebAssembly.compileStreaming(<em>source</em>);</pre>

<h3 id="Parameter">Parameter</h3>

<dl>
 <dt><em>source</em></dt>
 <dd>Ein {{domxref("Response")}} Objekt oder ein Promise das sich zu einem solchen auflöst. Es stellt die zugrunde liegende Quelle eines .wasm Moduls dar, die gestreamt und kompiliert werden soll.</dd>
</dl>

<h3 id="Rückgabewert">Rückgabewert</h3>

<p>Ein <code>Promise</code> das sich in ein {{jsxref("WebAssembly.Module")}} Objekt auflöst, welche das kompilierte Modul darstellt.</p>

<h3 id="Ausnahmen">Ausnahmen</h3>

<ul>
 <li>Wenn <code>bufferSource</code> kein <a href="/en-US/docs/Web/JavaScript/Typed_arrays">typisiertes Array<font color="#001000"> </font></a>ist, wird ein {{jsxref("TypeError")}} geworfen.</li>
 <li>Schlägt die Kompilierung fehl, wird das Promise mit einem {{jsxref("WebAssembly.CompileError")}} verworfen.</li>
</ul>

<h2 id="Beispiele">Beispiele</h2>

<p>Das folgende Beispiel (siehe unsere <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/compile-streaming.html">compile-streaming.html</a> Demo auf GitHub, und <a href="https://mdn.github.io/webassembly-examples/js-api-examples/compile-streaming.html">siehe das live Beispiel</a>) streamt ein .wasm Modul direkt aus der zugrunde liegenden Quelle und kompiliert es in ein {{jsxref("WebAssembly.Module")}} Objekt. Weil die <code>compileStreaming()</code>  Funktion ein Promise für ein {{domxref("Response")}} Objekt annimmt, kann ihr direkt ein  {{domxref("WindowOrWorkerGlobalScope.fetch()")}} Aufruf durchgereicht werden, woraufhin es die Antwort in diese Funktion abgibt, sobald das Promise sich erfüllt.</p>

<pre class="brush: js">var importObject = { imports: { imported_func: arg =&gt; console.log(arg) } };

WebAssembly.compileStreaming(fetch('simple.wasm'))
.then(module =&gt; WebAssembly.instantiate(module, importObject))
.then(instance =&gt; instance.exports.exported_func());</pre>

<p>Das resultierende Modul wird dann mittels {{jsxref("WebAssembly.instantiate()")}} instanziiert und die bereitgestellte Funktion wird aufgerufen.</p>

<h2 id="Spezifikationen">Spezifikationen</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Spezifikationen</th>
   <th scope="col">Status</th>
   <th scope="col">Kommentar</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('WebAssembly Embedding', '#webassemblycompilestreaming', 'compileStreaming()')}}</td>
   <td>{{Spec2('WebAssembly Embedding')}}</td>
   <td>Initial draft definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">Browserkompatibilität</h2>

<div>


<p>{{Compat("javascript.builtins.WebAssembly.compileStreaming")}}</p>
</div>

<h2 id="Siehe_auch">Siehe auch</h2>

<ul>
 <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> Übersichtsseite</li>
 <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
 <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
</ul>