Documentation
    Preparing search index...

    Class Conf<Schema>

    Simple config handling for your app or module.

    Type Parameters

    • Schema extends StandardSchemaV1
    Index
    • Creates a new config store.

      Type Parameters

      • Schema extends StandardSchemaV1<unknown, unknown>

      Parameters

      Returns Conf<Schema>

    events: EventTarget
    path: string
    • get size(): number

      Number of top-level config items.

      Returns number

    • get store(): SchemaValues<Schema>

      Get or replace the full config object.

      Reading this property loads and validates the config file from disk.

      Returns SchemaValues<Schema>

    • set store(value: SchemaValues<Schema>): void

      Validates value and persists the schema output. Missing top-level keys are filled from the defaults option and schema defaults.

      Parameters

      Returns void

    • Close the file watcher if one exists.

      Useful in tests to prevent the process from hanging.

      Returns void

    • Iterate over config entries as [key, value] pairs.

      Returns Generator<SchemaEntry<Schema>, void, unknown>

    • Append an item to an array config value.

      Creates the array when the key does not exist.

      Type Parameters

      • Key extends string | number | symbol | string & Record<never, never>

      Parameters

      Returns void

    • Reset the config to the defaults option and schema default values.

      Returns void

    • Delete a config item.

      Parameters

      Returns void

    • Get a config item.

      Type Parameters

      • Key extends string | number | symbol | string & Record<never, never>

      Parameters

      • key: Key

        Item key. Supports dot notation when enabled.

      Returns SchemaValue<Schema, Key>

    • Get a config item, falling back to a default value when missing.

      Type Parameters

      • Key extends string | number | symbol | string & Record<never, never>
      • DefaultValue

      Parameters

      • key: Key

        Item key. Supports dot notation when enabled.

      • defaultValue: DefaultValue

        Value returned when the item does not exist.

      Returns DefaultValue | Exclude<SchemaValue<Schema, Key>, undefined>

    • Check whether a config item exists.

      Parameters

      Returns boolean

    • Watch a config key for changes.

      Type Parameters

      • Key extends string | number | symbol | string & Record<never, never>

      Parameters

      Returns Unsubscribe

      Unsubscribe function.

    • Reset items to their default values.

      Values come from the defaults option first, then from the schema. Keys without a default are left unchanged.

      Parameters

      Returns void

    • Set one or more config items.

      Type Parameters

      • Key extends string | number | symbol | string & Record<never, never>

      Parameters

      Returns void

    • Set multiple config items.

      Parameters

      Returns void