Class BaseConfigStore<T, P>Abstract

An abstract class that implements all the config management functions but none of the storage functions.

Note: To see the interface, look in typescripts autocomplete help or the npm package's ConfigStore.d.ts file.

Type Parameters

Hierarchy

  • AsyncOptionalCreatable<T>

Implements

Methods

  • Invokes actionFn once for each key-value pair present in the config object.

    Parameters

    • actionFn: ((key, value) => void)

      The function (key: string, value: ConfigValue) => void to be called for each element.

        • (key, value): void
        • Parameters

          • key: string
          • value: AnyJson

          Returns void

    Returns void

  • Returns the value associated to the key, or undefined if there is none.

    Type Parameters

    • K extends string

    Parameters

    • key: K

      The key (object property)

    • Optional decrypt: boolean

      If it is an encrypted key, decrypt the value. If the value is an object, a clone will be returned.

    Returns P[K]

  • Type Parameters

    • V = AnyJson

    Parameters

    • key: string
    • Optional decrypt: boolean

    Returns V

  • Returns the entire config contents.

    NOTE: Data will still be encrypted unless decrypt is passed in. A clone of the data will be returned to prevent storing un-encrypted data in memory and potentially saving to the file system.

    Parameters

    • decrypt: boolean = false

    Returns Readonly<P>

  • Returns a boolean asserting whether a value has been associated to the key in the config object or not.

    Parameters

    • key: string

    Returns boolean

  • Returns an array that contains the keys for each element in the config object.

    Returns Extract<keyof P, string>[]

  • Sets the value for the key in the config object. This will override the existing value. To do a partial update, use BaseConfigStore.update.

    Type Parameters

    • K extends string

    Parameters

    • key: K

      The key.

    • value: P[K]

      The value.

    Returns void

  • Returns true if an element in the config object existed and has been removed, or false if the element does not exist. BaseConfigStore.has will return false afterwards.

    Type Parameters

    • K extends string

    Parameters

    • key: K

      The key

    Returns boolean

  • Returns true if all elements in the config object existed and have been removed, or false if all the elements do not exist (some may have been removed). (key) will return false afterwards.

    Parameters

    • keys: Extract<keyof P, string>[]

      The keys

    Returns boolean

  • Updates the value for the key in the config object. If the value is an object, it will be merged with the existing object.

    Type Parameters

    • K extends string

    Parameters

    • key: K

      The key.

    • value: Partial<P[K]>

      The value.

    Returns void