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
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