aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/idbkeyrange/includes
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/fr/web/api/idbkeyrange/includes
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/fr/web/api/idbkeyrange/includes')
-rw-r--r--files/fr/web/api/idbkeyrange/includes/index.html153
1 files changed, 153 insertions, 0 deletions
diff --git a/files/fr/web/api/idbkeyrange/includes/index.html b/files/fr/web/api/idbkeyrange/includes/index.html
new file mode 100644
index 0000000000..5b6071eba0
--- /dev/null
+++ b/files/fr/web/api/idbkeyrange/includes/index.html
@@ -0,0 +1,153 @@
+---
+title: IDBKeyRange.includes()
+slug: Web/API/IDBKeyRange/includes
+tags:
+ - API
+ - IDBKeyRange
+ - IndexedDB
+ - Méthode
+ - Reference
+translation_of: Web/API/IDBKeyRange/includes
+---
+<div>{{APIRef("IndexedDB")}}</div>
+
+<p>La méthode <code><strong>includes()</strong></code>, rattachée à l'interface {{domxref("IDBKeyRange")}}, renvoie un booléen si la clé est contenue dans un intervalle de clé.</p>
+
+<p>{{AvailableInWorkers}}</p>
+
+<h2 id="Syntaxe">Syntaxe</h2>
+
+<pre class="brush: js">myIncludesResult = myKeyRange.includes('A');</pre>
+
+<h3 id="Paramètres">Paramètres</h3>
+
+<dl>
+ <dt><code>key</code></dt>
+ <dd>La clé dont on souhaite savoir si elle est dans l'intervalle.</dd>
+</dl>
+
+<h3 id="Valeur_de_retour">Valeur de retour</h3>
+
+<p>Un booléen.</p>
+
+<h3 id="Exceptions">Exceptions</h3>
+
+<p>Cette méthode peut lever une exception {{domxref("DOMException")}} de type {{domxref("DataError")}} lorsque la clé fournie n'est pas une clé valide.</p>
+
+<h2 id="Exemples">Exemples</h2>
+
+<pre class="brush: js">var keyRangeValue = IDBKeyRange.bound('A', 'K', false, false);
+
+var monResultat = keyRangeValue.includes('F');
+// Renvoie true
+
+var monResultat = keyRangeValue.includes('W');
+// Renvoie false
+</pre>
+
+<h2 id="Spécifications">Spécifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Spécification</th>
+ <th scope="col">État</th>
+ <th scope="col">Commentaires</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('IndexedDB 2', '#dom-idbkeyrange-includes', 'includes()')}}</td>
+ <td>{{Spec2('IndexedDB')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Fonctionnalité</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari (WebKit)</th>
+ </tr>
+ <tr>
+ <td>Support simple</td>
+ <td>
+ <p>{{CompatChrome(52.0)}}</p>
+ </td>
+ <td>{{CompatGeckoDesktop("47.0")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatOpera(39)}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Fonctionnalité</th>
+ <th>Android</th>
+ <th>Webview Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>Firefox OS</th>
+ <th>IE Phone</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ <th>Chrome pour Android</th>
+ </tr>
+ <tr>
+ <td>Support simple</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatChrome(52.0)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatOperaMobile(39)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatChrome(52.0)}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="Prothèse_d'émulation_(polyfill)">Prothèse d'émulation (<em>polyfill</em>)</h2>
+
+<p>La méhode <code>includes()</code> a été ajoutée à partir de la deuxième édition de la spécification d'Indexed DB. Pour les navigateurs qui ne prennent pas en charge cette fonctionnalité, on peut utiliser la prothèse suivante.</p>
+
+<pre class="brush: js">IDBKeyRange.prototype.includes = IDBKeyRange.prototype.includes || function(key) {
+ var r = this, c;
+ if (r.lower !== undefined) {
+ c = indexedDB.cmp(key, r.lower);
+ if (r.lowerOpen &amp;&amp; c &lt;= 0) return false;
+ if (!r.lowerOpen &amp;&amp; c &lt; 0) return false;
+ }
+ if (r.upper !== undefined) {
+ c = indexedDB.cmp(key, r.upper);
+ if (r.upperOpen &amp;&amp; c &gt;= 0) return false;
+ if (!r.upperOpen &amp;&amp; c &gt; 0) return false;
+ }
+ return true;
+};
+</pre>
+
+<h2 id="Voir_aussi">Voir aussi</h2>
+
+<ul>
+ <li><a href="/fr/docs/Web/API/API_IndexedDB/Using_IndexedDB">Utiliser IndexedDB</a></li>
+ <li>Initier une connexion : {{domxref("IDBDatabase")}}</li>
+ <li>Utiliser les transactions : {{domxref("IDBTransaction")}}</li>
+ <li>Définir un intervalle de clés : {{domxref("IDBKeyRange")}}</li>
+ <li>Récupérer et modifier les données : {{domxref("IDBObjectStore")}}</li>
+ <li>Utiliser les curseurs {{domxref("IDBCursor")}}</li>
+ <li>Exemple de référence : <a class="external" href="https://github.com/mdn/to-do-notifications/tree/gh-pages">To-do Notifications</a> (<a class="external" href="https://mdn.github.io/to-do-notifications/">exemple <em>live</em></a>).</li>
+</ul>