WorkletSharedStorage: `length()` Methode

Experimentell: Dies ist eine experimentelle Technologie
Überprüfen Sie die Browser-Kompatibilitätstabelle sorgfältig vor der Verwendung auf produktiven Webseiten.

Die length()-Methode der WorkletSharedStorage-Schnittstelle gibt die Anzahl der aktuell im Shared Storage für den aktuellen Ursprung gespeicherten Einträge zurück.

Syntax

js
length()

Parameter

Keine.

Rückgabewert

Ein Promise, das mit einer Zahl erfüllt wird, die die Gesamtanzahl der aktuell im Shared Storage gespeicherten Schlüssel-Wert-Paare darstellt.

Ausnahmen

TypeError

Wird ausgelöst, wenn:

  • Das Worklet-Modul noch nicht mit addModule() hinzugefügt wurde.
  • Die aufrufende Stelle die Shared Storage API nicht in einem erfolgreichen Privacy Sandbox Einschreibungsprozess enthalten hat.
  • Der Browser aus einem anderen Grund die Anzahl der Einträge nicht abrufen kann.

Beispiele

js
// length() available inside a shared storage worklet module

async function retrieveLength() {
  const length = await this.sharedStorage.length();
  console.log(length);
}

Spezifikationen

No specification found

No specification data found for api.WorkletSharedStorage.length.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

Browser-Kompatibilität

No compatibility data found for api.WorkletSharedStorage.length.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.

Siehe auch