hoshimi
    Preparing search index...

    Class PlayerStorageAdapterAbstract

    Class representing a player storage adapter.

    PlayerStorageAdapter

    class MyPlayerStorageAdapter extends PlayerStorageAdapter {};

    const storage = new MyPlayerStorageAdapter();
    await storage.set("key", "value");

    const value = await storage.get("key");
    console.log(value); // "value"

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    namespace: string = "hoshimiplayer"

    The namespace of the storage.

    "hoshimiplayer"
    
    console.log(storage.namespace); // "hoshimiplayer"
    

    Methods

    • Get all key-value pairs in the storage.

      Type Parameters

      • K extends (string & {})[]
      • V extends unknown

      Returns Awaitable<Record<K[number], V>>

      An object containing all key-value pairs in the storage, excluding internal keys.

      const all = await storage.all();
      console.log(all); // { key1: "value1", key2: "value2" }
    • Delete the value using the key.

      Type Parameters

      • K extends string & {}

      Parameters

      • key: K

        The key to delete the value from.

      Returns Awaitable<boolean>

      Returns true if the key was deleted.

      const success = await storage.delete("key");
      console.log(success); // true
    • Get all entries in the storage.

      Type Parameters

      • K extends (string & {})[]
      • V extends unknown

      Returns Awaitable<[K, V][]>

      The entries in the storage.

      const entries = await storage.entries();
      console.log(entries); // [["key1", "value1"], ["key2", "value2"]]
    • Get the value using the key.

      Type Parameters

      • K extends string & {}
      • V extends unknown

      Parameters

      • key: K

        The key to get the value from.

      Returns Awaitable<V | undefined>

      The value of the key.

      const value = await storage.get("key");
      console.log(value); // "value"
    • Set the value using the key.

      Type Parameters

      • K extends string & {}
      • V extends unknown

      Parameters

      • key: K

        The key to set the value to.

      • value: V

        The value to set.

      Returns Awaitable<void>

      Did you know this can be async?

      await storage.set("key", "value");