From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/fr/web/api/idbkeyrange/includes/index.html | 153 +++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 files/fr/web/api/idbkeyrange/includes/index.html (limited to 'files/fr/web/api/idbkeyrange/includes') 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 +--- +
{{APIRef("IndexedDB")}}
+ +

La méthode includes(), rattachée à l'interface {{domxref("IDBKeyRange")}}, renvoie un booléen si la clé est contenue dans un intervalle de clé.

+ +

{{AvailableInWorkers}}

+ +

Syntaxe

+ +
myIncludesResult = myKeyRange.includes('A');
+ +

Paramètres

+ +
+
key
+
La clé dont on souhaite savoir si elle est dans l'intervalle.
+
+ +

Valeur de retour

+ +

Un booléen.

+ +

Exceptions

+ +

Cette méthode peut lever une exception {{domxref("DOMException")}} de type {{domxref("DataError")}} lorsque la clé fournie n'est pas une clé valide.

+ +

Exemples

+ +
var keyRangeValue = IDBKeyRange.bound('A', 'K', false, false);
+
+var monResultat = keyRangeValue.includes('F');
+// Renvoie true
+
+var monResultat = keyRangeValue.includes('W');
+// Renvoie false
+
+ +

Spécifications

+ + + + + + + + + + + + + + +
SpécificationÉtatCommentaires
{{SpecName('IndexedDB 2', '#dom-idbkeyrange-includes', 'includes()')}}{{Spec2('IndexedDB')}} 
+ +

Compatibilité des navigateurs

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FonctionnalitéChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Support simple +

{{CompatChrome(52.0)}}

+
{{CompatGeckoDesktop("47.0")}}{{CompatUnknown}}{{CompatOpera(39)}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
FonctionnalitéAndroidWebview AndroidFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari MobileChrome pour Android
Support simple{{CompatNo}}{{CompatChrome(52.0)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatOperaMobile(39)}}{{CompatUnknown}}{{CompatChrome(52.0)}}
+
+ +

Prothèse d'émulation (polyfill)

+ +

La méhode includes() 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.

+ +
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 && c <= 0) return false;
+    if (!r.lowerOpen && c < 0) return false;
+  }
+  if (r.upper !== undefined) {
+    c = indexedDB.cmp(key, r.upper);
+    if (r.upperOpen && c >= 0) return false;
+    if (!r.upperOpen && c > 0) return false;
+  }
+  return true;
+};
+
+ +

Voir aussi

+ + -- cgit v1.2.3-54-g00ecf