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/validate | |
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/validate')
-rw-r--r-- | files/fr/web/javascript/reference/global_objects/webassembly/validate/index.md | 80 |
1 files changed, 32 insertions, 48 deletions
diff --git a/files/fr/web/javascript/reference/global_objects/webassembly/validate/index.md b/files/fr/web/javascript/reference/global_objects/webassembly/validate/index.md index df8887431d..2098e3eb62 100644 --- a/files/fr/web/javascript/reference/global_objects/webassembly/validate/index.md +++ b/files/fr/web/javascript/reference/global_objects/webassembly/validate/index.md @@ -10,69 +10,53 @@ tags: translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/validate original_slug: Web/JavaScript/Reference/Objets_globaux/WebAssembly/validate --- -<div>{{JSRef}}</div> +{{JSRef}} -<p>La fonction <strong><code>WebAssembly.validate()</code></strong> permet de valider un <a href="/fr/docs/Web/JavaScript/Tableaux_typés">tableau typé</a> de <em>bytecode</em> WebAssembly et renvoie un booléen qui indique si le contenu du tableau forme un module WebAssembly valide (<code>true</code>) ou non (<code>false</code>).</p> +La fonction **`WebAssembly.validate()`** permet de valider un [tableau typé](/fr/docs/Web/JavaScript/Tableaux_typés) de _bytecode_ WebAssembly et renvoie un booléen qui indique si le contenu du tableau forme un module WebAssembly valide (`true`) ou non (`false`). -<h2 id="Syntaxe">Syntaxe</h2> +## Syntaxe -<pre class="syntaxbox">WebAssembly.validate(bufferSource);</pre> + WebAssembly.validate(bufferSource); -<h3 id="Paramètres">Paramètres</h3> +### Paramètres -<dl> - <dt><code>bufferSource</code></dt> - <dd>Un <a href="/fr/docs/Web/JavaScript/Reference/Objets_globaux/TypedArray">tableau typé</a> ou un {{jsxref("ArrayBuffer")}} qui contient le <em>bytecode</em> du module qu'on souhaite valider.</dd> -</dl> +- `bufferSource` + - : Un [tableau typé](/fr/docs/Web/JavaScript/Reference/Objets_globaux/TypedArray) ou un {{jsxref("ArrayBuffer")}} qui contient le _bytecode_ du module qu'on souhaite valider. -<h3 id="Valeur_de_retour">Valeur de retour</h3> +### Valeur de retour -<p>Un booléen qui indique si la source est un code WebAssembly valide (<code>true</code>) ou non (<code>false</code>).</p> +Un booléen qui indique si la source est un code WebAssembly valide (`true`) ou non (`false`). -<h3 id="Exceptions">Exceptions</h3> +### Exceptions -<p>Si la valeur passée en argument n'est pas un tableau typé ou un {{jsxref("ArrayBuffer")}}, une exception {{jsxref("TypeError")}} sera levée.</p> +Si la valeur passée en argument n'est pas un tableau typé ou un {{jsxref("ArrayBuffer")}}, une exception {{jsxref("TypeError")}} sera levée. -<h2 id="Exemples">Exemples</h2> +## Exemples -<p>Dans l'exemple suivant, (cf. le fichier <code>validate.html</code> du <a href="https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/validate.html">code source</a>, ainsi que <a href="https://mdn.github.io/webassembly-examples/js-api-examples/validate.html">l'exemple <em>live</em></a>), on récupère un module .wasm et on le convertit en un tableau typé. Ensuite, on appelle la méthode <code>validate()</code> afin de vérifier si le module est valide.</p> +Dans l'exemple suivant, (cf. le fichier `validate.html` du [code source](https://github.com/mdn/webassembly-examples/blob/master/js-api-examples/validate.html), ainsi que [l'exemple _live_](https://mdn.github.io/webassembly-examples/js-api-examples/validate.html)), on récupère un module .wasm et on le convertit en un tableau typé. Ensuite, on appelle la méthode `validate()` afin de vérifier si le module est valide. -<pre class="brush: js">fetch('simple.wasm').then(response => +```js +fetch('simple.wasm').then(response => response.arrayBuffer() ).then(function(bytes) { var valid = WebAssembly.validate(bytes); console.log("Les octets forment un module " + (valid ? "" : "in") + "valide."); }); -</pre> - -<h2 id="Spécifications">Spécifications</h2> - -<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', '#webassemblyvalidate', 'validate()')}}</td> - <td>{{Spec2('WebAssembly JS')}}</td> - <td>Brouillon de définition initiale pour WebAssembly.</td> - </tr> - </tbody> -</table> - -<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> - -<p>{{Compat("javascript.builtins.WebAssembly.validate")}}</p> - -<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> +``` + +## Spécifications + +| Spécification | État | Commentaires | +| -------------------------------------------------------------------------------------------- | ------------------------------------ | -------------------------------------------------- | +| {{SpecName('WebAssembly JS', '#webassemblyvalidate', 'validate()')}} | {{Spec2('WebAssembly JS')}} | Brouillon de définition initiale pour WebAssembly. | + +## Compatibilité des navigateurs + +{{Compat("javascript.builtins.WebAssembly.validate")}} + +## Voir aussi + +- [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) |