Options
All
  • Public
  • Public/Protected
  • All
Menu

A model for preferences. The preferences stored in this object must be serializable as JSON. The class itself does not enforce this, so callers must be careful.

Hierarchy

  • Preferences

Index

Constructors

Properties

Methods

Constructors

constructor

  • new Preferences(initial?: undefined | __type): Preferences
  • throws

    {Error} If there is any error in the preferences.

    Parameters

    • Optional initial: undefined | __type

      initial preferences.

    Returns Preferences

Properties

Private prefs

prefs: __type

Methods

_validatePrefs

  • _validatePrefs(prefs: __type): void
  • Validates a set of preferences.

    throws

    {Error} If there is any error in the preferences.

    Parameters

    • prefs: __type

      The preferences to validate.

    Returns void

get

  • get(name: string): any
  • Gets a preference value.

    throws

    {Error} If name is malformed.

    Parameters

    • name: string

      The preference to get. This name may be hierarchical: "foo.bar" would get the value of "bar" in "foo".

    Returns any

    The value of the preference. If the preference does not exist, the value is undefined.

set

  • set(name: string, value: any): void
  • Sets a preference value. This method fails hard if the value added to the preferences object is invalid somehow, but it fails after modifying the preferences. This method is not meant to validate user input.

    throws

    {Error} If name is malformed, if any part of the name does not exist, or if the resulting preference objects is invalid.

    Parameters

    • name: string

      The preference to get. This name may be hierarchical: "foo.bar" would get the value of "bar" in "foo".

    • value: any

      The value to set the preference to.

    Returns void

Generated using TypeDoc