aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/javascript/reference/global_objects/webassembly/instance
diff options
context:
space:
mode:
authorjulieng <julien.gattelier@gmail.com>2021-08-03 08:03:23 +0200
committerSphinxKnight <SphinxKnight@users.noreply.github.com>2021-09-03 08:08:25 +0200
commitbf8e099b9c8b3c60d60b3712b4fc97b052c39887 (patch)
treec101746d082c9581c94f5937519c7d0e2f4af8cb /files/fr/web/javascript/reference/global_objects/webassembly/instance
parent844f5103992238c0c23203286dad16a466e89c97 (diff)
downloadtranslated-content-bf8e099b9c8b3c60d60b3712b4fc97b052c39887.tar.gz
translated-content-bf8e099b9c8b3c60d60b3712b4fc97b052c39887.tar.bz2
translated-content-bf8e099b9c8b3c60d60b3712b4fc97b052c39887.zip
convert content to md
Diffstat (limited to 'files/fr/web/javascript/reference/global_objects/webassembly/instance')
-rw-r--r--files/fr/web/javascript/reference/global_objects/webassembly/instance/exports/index.md55
-rw-r--r--files/fr/web/javascript/reference/global_objects/webassembly/instance/index.md73
2 files changed, 47 insertions, 81 deletions
diff --git a/files/fr/web/javascript/reference/global_objects/webassembly/instance/exports/index.md b/files/fr/web/javascript/reference/global_objects/webassembly/instance/exports/index.md
index 86bece9671..6a18d00743 100644
--- a/files/fr/web/javascript/reference/global_objects/webassembly/instance/exports/index.md
+++ b/files/fr/web/javascript/reference/global_objects/webassembly/instance/exports/index.md
@@ -12,17 +12,18 @@ tags:
translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance/exports
original_slug: Web/JavaScript/Reference/Objets_globaux/WebAssembly/Instance/exports
---
-<div>{{JSRef}}</div>
+{{JSRef}}
-<p>La propriété <strong><code>exports</code></strong> du prototype de {{jsxref("WebAssembly.Instance")}} est une propriété en lecture seul qui renvoie un objet dont les propriétés sont les différentes fonctions exportées depuis l'instance du module WebAssembly. Cela permet d'y accéder et de les manipuler en JavaScript.</p>
+La propriété **`exports`** du prototype de {{jsxref("WebAssembly.Instance")}} est une propriété en lecture seul qui renvoie un objet dont les propriétés sont les différentes fonctions exportées depuis l'instance du module WebAssembly. Cela permet d'y accéder et de les manipuler en JavaScript.
-<pre class="syntaxbox">instance.exports</pre>
+ instance.exports
-<h2 id="Exemples">Exemples</h2>
+## Exemples
-<p>Après avoir récupéré le <em>bytecode</em> WebAssembly grâce à la méthode <code>fetch()</code>, on le compile et on instancie le module grâce à la fonction {{jsxref("WebAssembly.instantiateStreaming()")}}. Lorsqu'on utilise cette fonction, on importe une fonction dans le module. Ensuite, on appelle <a href="/fr/docs/WebAssembly/Exported_functions">une fonction WebAssembly exportée</a> qui est exposée via l'instance.</p>
+Après avoir récupéré le _bytecode_ WebAssembly grâce à la méthode `fetch()`, on le compile et on instancie le module grâce à la fonction {{jsxref("WebAssembly.instantiateStreaming()")}}. Lorsqu'on utilise cette fonction, on importe une fonction dans le module. Ensuite, on appelle [une fonction WebAssembly exportée](/fr/docs/WebAssembly/Exported_functions) qui est exposée via l'instance.
-<pre class="brush: js">var importObject = {
+```js
+var importObject = {
imports: {
imported_func: function(arg) {
console.log(arg);
@@ -30,39 +31,23 @@ original_slug: Web/JavaScript/Reference/Objets_globaux/WebAssembly/Instance/expo
}
};
WebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject)
-.then(obj =&gt; obj.instance.exports.exported_func());</pre>
+.then(obj => obj.instance.exports.exported_func());
+```
-<div class="note">
-<p><strong>Note :</strong> Voir le fichier <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/index.html">index.html</a> sur GitHub (ainsi que <a href="https://mdn.github.io/webassembly-examples/js-api-examples/">la démonstration</a>) pour un exemple.</p>
-</div>
+> **Note :** Voir le fichier [index.html](https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/index.html) sur GitHub (ainsi que [la démonstration](https://mdn.github.io/webassembly-examples/js-api-examples/)) pour un exemple.
-<h2 id="Spécifications">Spécifications</h2>
+## Spécifications
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">Spécification</th>
- <th scope="col">État</th>
- <th scope="col">Commentaires</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{{SpecName('WebAssembly JS', '#webassemblyinstance-objects', 'WebAssembly.Instance objects')}}</td>
- <td>{{Spec2('WebAssembly JS')}}</td>
- <td>Brouillon de définition initiale pour WebAssembly.</td>
- </tr>
- </tbody>
-</table>
+| Spécification | État | Commentaires |
+| ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | -------------------------------------------------- |
+| {{SpecName('WebAssembly JS', '#webassemblyinstance-objects', 'WebAssembly.Instance objects')}} | {{Spec2('WebAssembly JS')}} | Brouillon de définition initiale pour WebAssembly. |
-<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
+## Compatibilité des navigateurs
-<p>{{Compat("javascript.builtins.WebAssembly.Instance.exports")}}</p>
+{{Compat("javascript.builtins.WebAssembly.Instance.exports")}}
-<h2 id="Voir_aussi">Voir aussi</h2>
+## Voir aussi
-<ul>
- <li><a href="/fr/docs/WebAssembly">Le portail WebAssembly</a></li>
- <li><a href="/fr/docs/WebAssembly/Concepts">Les concepts relatifs à WebAssembly</a></li>
- <li><a href="/fr/docs/WebAssembly/Using_the_JavaScript_API">Utiliser l'API JavaScript WebAssembly</a></li>
-</ul>
+- [Le portail WebAssembly](/fr/docs/WebAssembly)
+- [Les concepts relatifs à WebAssembly](/fr/docs/WebAssembly/Concepts)
+- [Utiliser l'API JavaScript WebAssembly](/fr/docs/WebAssembly/Using_the_JavaScript_API)
diff --git a/files/fr/web/javascript/reference/global_objects/webassembly/instance/index.md b/files/fr/web/javascript/reference/global_objects/webassembly/instance/index.md
index 1fceef26d9..3c06a69d03 100644
--- a/files/fr/web/javascript/reference/global_objects/webassembly/instance/index.md
+++ b/files/fr/web/javascript/reference/global_objects/webassembly/instance/index.md
@@ -11,68 +11,49 @@ tags:
translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance
original_slug: Web/JavaScript/Reference/Objets_globaux/WebAssembly/Instance
---
-<div>{{JSRef}}</div>
+{{JSRef}}
-<p>Un objet <strong><code>WebAssembly.Instance</code></strong> représente un objet exécutable, avec un état, qui est une instance d'un <a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Module">module WebAssembly</a>. Un objet <code>Instance</code> contient l'ensemble <a href="/fr/docs/WebAssembly/Exported_functions">des fonctions WebAssembly exportées</a> qui permettent d'invoquer du code WebAssembly depuis du code JavaScript.</p>
+Un objet **`WebAssembly.Instance`** représente un objet exécutable, avec un état, qui est une instance d'un [module WebAssembly](/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Module). Un objet `Instance` contient l'ensemble [des fonctions WebAssembly exportées](/fr/docs/WebAssembly/Exported_functions) qui permettent d'invoquer du code WebAssembly depuis du code JavaScript.
-<p>Le constructeur <code>WebAssembly.Instance()</code> peut être appelé afin de créer, de façon synchrone, une instance d'un {{jsxref("WebAssembly.Module")}} donné. Toutefois, pour obtenir une instance, on utilisera généralement la fonction asynchrone {{jsxref("WebAssembly.instantiateStreaming()")}}.</p>
+Le constructeur `WebAssembly.Instance()` peut être appelé afin de créer, de façon synchrone, une instance d'un {{jsxref("WebAssembly.Module")}} donné. Toutefois, pour obtenir une instance, on utilisera généralement la fonction asynchrone {{jsxref("WebAssembly.instantiateStreaming()")}}.
-<h2 id="Syntaxe">Syntaxe</h2>
+## Syntaxe
-<div class="warning">
-<p><strong>Attention :</strong>L'instanciation de modules volumineux peut être coûteuse en temps/ressource. <code>Instance()</code> ne doit être utilisée que lorsqu'une instanciation synchrone est nécessaire. Pour tous les autres cas, c'est la méthode {{jsxref("WebAssembly.instantiateStreaming()")}} qui devrait être utilisée.</p>
-</div>
+> **Attention :**L'instanciation de modules volumineux peut être coûteuse en temps/ressource. `Instance()` ne doit être utilisée que lorsqu'une instanciation synchrone est nécessaire. Pour tous les autres cas, c'est la méthode {{jsxref("WebAssembly.instantiateStreaming()")}} qui devrait être utilisée.
-<pre class="syntaxbox">var monInstance = new WebAssembly.Instance(<em>module</em>, <em>importObject</em>);</pre>
+ var monInstance = new WebAssembly.Instance(module, importObject);
-<h3 id="Paramètres">Paramètres</h3>
+### Paramètres
-<dl>
- <dt><code>module</code></dt>
- <dd>L'objet <a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Module" title="The Module() constructor of the WebAssembly global object creates a new Module object instance."><code>WebAssembly.Module</code></a> qu'on souhaite instancier.</dd>
- <dt><code>importObject</code> {{optional_inline}}</dt>
- <dd>Un objet qui contient des valeurs à importer dans l'instance. Ce peuvent être des fonctions ou des objets <a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Memory" title="The Memory() constructor of the WebAssembly global object creates a new Memory object instance, which represents a WebAssembly memory. These can be thought of as resizeable array buffers, wrappers around WebAssembly memories."><code>WebAssembly.Memory</code></a>. Il doit exister une propriété correspondante pour chaque import, si ce n'est pas le cas, un exception <code><a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/LinkError">WebAssembly.LinkError</a></code> sera levée.</dd>
-</dl>
+- `module`
+ - : L'objet [`WebAssembly.Module`](/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Module "The Module() constructor of the WebAssembly global object creates a new Module object instance.") qu'on souhaite instancier.
+- `importObject` {{optional_inline}}
+ - : Un objet qui contient des valeurs à importer dans l'instance. Ce peuvent être des fonctions ou des objets [`WebAssembly.Memory`](/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Memory "The Memory() constructor of the WebAssembly global object creates a new Memory object instance, which represents a WebAssembly memory. These can be thought of as resizeable array buffers, wrappers around WebAssembly memories."). Il doit exister une propriété correspondante pour chaque import, si ce n'est pas le cas, un exception [`WebAssembly.LinkError`](/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/LinkError) sera levée.
-<h2 id="Instances_d'Instance">Instances d'<code>Instance</code></h2>
+## Instances d'`Instance`
-<p>Toutes les instances du type <code>Instance</code> héritent du prototype du constructeur <code>Instance()</code>. Celui-ci peut être modifié afin de modifier l'ensemble des instances de <code>Instance</code>.</p>
+Toutes les instances du type `Instance` héritent du prototype du constructeur `Instance()`. Celui-ci peut être modifié afin de modifier l'ensemble des instances de `Instance`.
-<h3 id="Propriétés">Propriétés</h3>
+### Propriétés
-<p>{{page('/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Instance/prototype', 'Propriétés')}}</p>
+{{page('/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Instance/prototype', 'Propriétés')}}
-<h3 id="Méthodes">Méthodes</h3>
+### Méthodes
-<p>{{page('/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Instance/prototype', 'Méthodes')}}</p>
+{{page('/fr/docs/Web/JavaScript/Reference/Objets_globaux/WebAssembly/Instance/prototype', 'Méthodes')}}
-<h2 id="Spécifications">Spécifications</h2>
+## Spécifications
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">Spécification</th>
- <th scope="col">État</th>
- <th scope="col">Commentaires</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{{SpecName('WebAssembly JS', '#webassemblyinstance-objects', 'Instance')}}</td>
- <td>{{Spec2('WebAssembly JS')}}</td>
- <td>Définition initiale dans un brouillon de spécification.</td>
- </tr>
- </tbody>
-</table>
+| Spécification | État | Commentaires |
+| ---------------------------------------------------------------------------------------------------- | ------------------------------------ | ------------------------------------------------------- |
+| {{SpecName('WebAssembly JS', '#webassemblyinstance-objects', 'Instance')}} | {{Spec2('WebAssembly JS')}} | Définition initiale dans un brouillon de spécification. |
-<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
+## Compatibilité des navigateurs
-<p>{{Compat("javascript.builtins.WebAssembly.Instance")}}</p>
+{{Compat("javascript.builtins.WebAssembly.Instance")}}
-<h2 id="Voir_aussi">Voir aussi</h2>
+## Voir aussi
-<ul>
- <li><a href="/fr/docs/WebAssembly">Le portail WebAssembly</a></li>
- <li><a href="/fr/docs/WebAssembly/Concepts">Les concepts relatifs à WebAssembly</a></li>
- <li><a href="/fr/docs/WebAssembly/Using_the_JavaScript_API">Utiliser l'API JavaScript WebAssembly</a></li>
-</ul>
+- [Le portail WebAssembly](/fr/docs/WebAssembly)
+- [Les concepts relatifs à WebAssembly](/fr/docs/WebAssembly/Concepts)
+- [Utiliser l'API JavaScript WebAssembly](/fr/docs/WebAssembly/Using_the_JavaScript_API)