Uses a JSON file to store key/value pairs.

Hierarchy

  • JsonFileStorage

Implements

Constructors

Properties

filePath: string
lockIdentifier: ResourceIdentifier

Methods

  • Deletes the value stored for the given key.

    Returns

    If there was a value to delete.

    Parameters

    • key: string

      Key to delete.

    Returns Promise<boolean>

  • An iterable of entries in the storage.

    Returns AsyncIterableIterator<[string, unknown]>

  • Returns the value stored for the given identifier. undefined if no value is stored.

    Parameters

    • key: string

    Returns Promise<unknown>

  • Checks if there is a value stored for the given key.

    Parameters

    • key: string

    Returns Promise<boolean>

  • Updates the data in the JSON file while using a write lock.

    Returns

    The return value of updateFn.

    Type Parameters

    • T

    Parameters

    • updateFn: ((json: Dict<unknown>) => T)

      A function that updates the JSON object.

        • (json: Dict<unknown>): T
        • Parameters

          • json: Dict<unknown>

          Returns T

    Returns Promise<T>