Config
Class
Config
Hierarchy
Homefront
↳ Config
Index
Constructors
Properties
Methods
- all
- applyDefaults
- expand
- fetch
- fetchOrPut
- flatten
- getData
- getMode
- isModeFlat
- isModeNested
- merge
- of
- put
- remove
- search
- setMode
- merge
Constructors
constructor
new Config(data?: __type
, mode?: string
): Config
Inherited from Homefront.__constructor
**
Constructs a new instance of Homefront.
Parameters:
Name | Type |
---|---|
Optional data | __type |
Optional mode | string |
Returns: Config
Properties
Static
MODE_FLAT
MODE_FLAT: string
Inherited from Homefront.MODE_FLAT
**
returns:
Static
MODE_NESTED
MODE_NESTED: string
Inherited from Homefront.MODE_NESTED
**
returns:
Methods
all
all(): ConfigInterface
Defined in Library/Config/Config.ts:5
Returns: ConfigInterface
applyDefaults
applyDefaults(key?: string
, defaults?: any
): any
Inherited from Homefront.applyDefaults
**
Method allowing you to set missing keys (backwards-applied defaults) nested.
Parameters:
Name | Type | Description |
---|---|---|
Optional key | string | - |
Optional defaults | any |
Returns: any
expand
expand(source?: __type
): __type
Inherited from Homefront.expand
**
Expands flat object to nested object.
Parameters:
Name | Type |
---|---|
Optional source | __type |
Returns: __type
fetch
fetch(key?: string
, defaultValue?: any
): any
Inherited from Homefront.fetch
**
Fetches value of given key.
Parameters:
Name | Type | Description |
---|---|---|
Optional key | string | - |
Optional defaultValue | any |
Returns: any
fetchOrPut
fetchOrPut(key: string
, toPut: any
): any
Inherited from Homefront.fetchOrPut
**
Convenience method. Calls .fetch(), and on null result calls .put() using provided toPut.
Parameters:
Name | Type | Description |
---|---|---|
key | string | - |
toPut | any |
Returns: any
flatten
flatten(source?: __type
, basePath?: string
, target?: __type
): __type
Inherited from Homefront.flatten
**
Flattens nested object (dot separated keys).
Parameters:
Name | Type |
---|---|
Optional source | __type |
Optional basePath | string |
Optional target | __type |
Returns: __type
getData
getData(): __type
Inherited from Homefront.getData
**
Get data object.
Returns: __type
getMode
getMode(): string
Inherited from Homefront.getMode
**
Gets the mode.
Returns: string
isModeFlat
isModeFlat(): boolean
Inherited from Homefront.isModeFlat
**
Returns whether or not mode is flat.
Returns: boolean
isModeNested
isModeNested(): boolean
Inherited from Homefront.isModeNested
**
Returns whether or not mode is nested.
Returns: boolean
merge
merge(...sources: Array
< __type
| Homefront
>): Homefront
Inherited from Homefront.merge
**
Recursively merges given sources into data.
Parameters:
Name | Type |
---|---|
Rest sources | Array < __type | Homefront > |
Returns: Homefront
of
of<T
>(section: string
): T
Defined in Library/Config/Config.ts:9
Type parameters:
T
Parameters:
Name | Type |
---|---|
section | string |
Returns: T
put
put(key?: * string
| Array
<string
>*, value?: any
): Homefront
Inherited from Homefront.put
**
Sets value for a key.
Parameters:
Name | Type | Description |
---|---|---|
Optional key | string | Array <string > | Array of key parts, or dot separated key. |
Optional value | any |
Returns: Homefront
remove
remove(key?: string
): Homefront
Inherited from Homefront.remove
**
Removes value by key.
Parameters:
Name | Type | Description |
---|---|---|
Optional key | string |
Returns: Homefront
search
search(phrase?: * string
| number
*): Array
<any
>
Inherited from Homefront.search
**
Search and return keys and values that match given string.
Parameters:
Name | Type | Description |
---|---|---|
Optional phrase | string | number |
Returns: Array
<any
>
setMode
setMode(mode?: string
): Homefront
Inherited from Homefront.setMode
**
Sets the mode. throws: {Error}
Parameters:
Name | Type |
---|---|
Optional mode | string |
Returns: Homefront
Fluent interface
Static
merge
merge(...sources: Array
< __type
| Homefront
>): __type
Inherited from Homefront.merge
**
Static version of merge, allowing you to merge objects together.
Parameters:
Name | Type | Description |
---|---|---|
Rest sources | Array < __type | Homefront > | One or more, or array of, objects to merge into data (left to right). |
Returns: __type