diff options
| author | julieng <julien.gattelier@gmail.com> | 2021-08-03 08:03:23 +0200 |
|---|---|---|
| committer | SphinxKnight <SphinxKnight@users.noreply.github.com> | 2021-09-03 08:08:25 +0200 |
| commit | bf8e099b9c8b3c60d60b3712b4fc97b052c39887 (patch) | |
| tree | c101746d082c9581c94f5937519c7d0e2f4af8cb /files/fr/web/javascript/reference/global_objects/webassembly/table/get | |
| parent | 844f5103992238c0c23203286dad16a466e89c97 (diff) | |
| download | translated-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/table/get')
| -rw-r--r-- | files/fr/web/javascript/reference/global_objects/webassembly/table/get/index.md | 76 |
1 files changed, 28 insertions, 48 deletions
diff --git a/files/fr/web/javascript/reference/global_objects/webassembly/table/get/index.md b/files/fr/web/javascript/reference/global_objects/webassembly/table/get/index.md index 717a8d70e1..3d263884fe 100644 --- a/files/fr/web/javascript/reference/global_objects/webassembly/table/get/index.md +++ b/files/fr/web/javascript/reference/global_objects/webassembly/table/get/index.md @@ -11,74 +11,54 @@ tags: translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Table/get original_slug: Web/JavaScript/Reference/Objets_globaux/WebAssembly/Table/get --- -<div>{{JSRef}}</div> +{{JSRef}} -<p>La méthode <code><strong>get()</strong></code>, rattachéee au prototype de {{jsxref("WebAssembly.Table()")}}, permet de récupérer une référence à une fonction stockée dans le tableau WebAssembly grâce à sa position. dans le tableau.</p> +La méthode **`get()`**, rattachéee au prototype de {{jsxref("WebAssembly.Table()")}}, permet de récupérer une référence à une fonction stockée dans le tableau WebAssembly grâce à sa position. dans le tableau. -<h2 id="Syntaxe">Syntaxe</h2> +## Syntaxe -<pre class="syntaxbox">var funcRef = table.get(<em>index</em>); -</pre> + var funcRef = table.get(index); -<h3 id="Paramètres">Paramètres</h3> +### Paramètres -<dl> - <dt><code>index</code></dt> - <dd>L'index de la référence de fonction qu'on souhaite récupérer.</dd> -</dl> +- `index` + - : L'index de la référence de fonction qu'on souhaite récupérer. -<h3 id="Valeur_de_retour">Valeur de retour</h3> +### Valeur de retour -<p>Une référence de fonction, c'est-à-dire <a href="/fr/docs/WebAssembly/Exported_functions">une fonction WebAssembly exportée</a> qui est une enveloppe JavaScript pour manipuler la fonction WebAssembly sous-jacente.</p> +Une référence de fonction, c'est-à-dire [une fonction WebAssembly exportée](/fr/docs/WebAssembly/Exported_functions) qui est une enveloppe JavaScript pour manipuler la fonction WebAssembly sous-jacente. -<h3 id="Exceptions">Exceptions</h3> +### Exceptions -<p>Si <code>index</code> est supérieur ou égal à {{jsxref("WebAssembly/Table/length","Table.prototype.length")}}, la méthode lèvera une exception {{jsxref("RangeError")}}.</p> +Si `index` est supérieur ou égal à {{jsxref("WebAssembly/Table/length","Table.prototype.length")}}, la méthode lèvera une exception {{jsxref("RangeError")}}. -<h2 id="Exemples">Exemples</h2> +## Exemples -<p>Dans l'exemple suivant (cf. le fichier <code><a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/table.html">table.html</a></code> sur GitHub ainsi que <a href="https://mdn.github.io/webassembly-examples/js-api-examples/table.html">le résultat obtenu</a>), on compile et on instancie le <em>bytecode</em> chargé, <code>table.wasm</code>, grâce à la méthode {{jsxref("WebAssembly.instantiateStreaming()")}}. On récupère ensuite les références stockées dans le tableau d'export.</p> +Dans l'exemple suivant (cf. le fichier [`table.html`](https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/table.html) sur GitHub ainsi que [le résultat obtenu](https://mdn.github.io/webassembly-examples/js-api-examples/table.html)), on compile et on instancie le _bytecode_ chargé, `table.wasm`, grâce à la méthode {{jsxref("WebAssembly.instantiateStreaming()")}}. On récupère ensuite les références stockées dans le tableau d'export. -<pre class="brush: js">WebAssembly.instantiateStreaming(fetch('table.wasm')) +```js +WebAssembly.instantiateStreaming(fetch('table.wasm')) .then(function(obj) { var tbl = obj.instance.exports.tbl; console.log(tbl.get(0)()); // 13 console.log(tbl.get(1)()); // 42 -});</pre> +}); +``` -<p>On note ici qu'il est nécessaire d'avoir un deuxième opérateur d'appel après l'accesseur pour récupérer le valeur stockée dans la référence (autrement dit, on utilise <code>get(0)()</code> plutôt que <code>get(0)</code>). La valeur exportée est une fonction plutôt qu'une valeur simple.</p> +On note ici qu'il est nécessaire d'avoir un deuxième opérateur d'appel après l'accesseur pour récupérer le valeur stockée dans la référence (autrement dit, on utilise `get(0)()` plutôt que `get(0)`). La valeur exportée est une fonction plutôt qu'une valeur simple. -<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', '#webassemblytableprototypeget', 'get()')}}</td> - <td>{{Spec2('WebAssembly JS')}}</td> - <td>Brouillon de définition initial pour WebAssembly.</td> - </tr> - </tbody> -</table> +| Spécification | État | Commentaires | +| ------------------------------------------------------------------------------------------------ | ------------------------------------ | ------------------------------------------------- | +| {{SpecName('WebAssembly JS', '#webassemblytableprototypeget', 'get()')}} | {{Spec2('WebAssembly JS')}} | Brouillon de définition initial pour WebAssembly. | -<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> +## Compatibilité des navigateurs -<div> +{{Compat("javascript.builtins.WebAssembly.Table.get")}} +## Voir aussi -<p>{{Compat("javascript.builtins.WebAssembly.Table.get")}}</p> -</div> - -<h2 id="Voir_aussi">Voir aussi</h2> - -<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) |
