Class: OptionStore

OptionStore()

A type-based option store that manages configuration data in a JSON-compatible object.

Each option is stored by the class name (constructor name) and can be retrieved for a given class or its ancestors.

Constructor

new OptionStore()

Example
class Base {}
class Derived extends Base {}

const store = OptionStore.as({});
store.set(Base, 'color', 'blue');
store.set(Derived, 'color', 'red');

store.get(Derived, 'color'); // → 'red'
store.get(Base, 'color');    // → 'blue'

Classes

OptionStore

Methods

get(type, key) → {*}

Retrieves an option value for a given class and key. Walks up the inheritance chain to find the first ancestor with a matching option.

Parameters:
Name Type Description
type function

The class (constructor) to inspect.

key string

The option key to look up.

Returns:

The found option value, or undefined if not found.

Type
*

set(type, key, value) → {this}

Sets an option for a given class.

Parameters:
Name Type Description
type function

The class (constructor) for which to store the option.

key string

The option key.

value *

The option value.

Returns:
Type
this