Class: Namespace
@ima/core.Namespace
Namespace creation, manipulation and traversal utility. This utility is used to create semi-global shared namespaces for registering references to interfaces, classes and constants of the application to provide access to each other more easily than by using the ES6 import/export mechanism.
Indexable
▪ [key: PropertyKey
]: any
Constructors
constructor
• new Namespace()
Methods
#resolvePathLevels
▸ Private
#resolvePathLevels(path
): string
[]
Resolve path levels from string
Parameters
Name | Type | Description |
---|---|---|
path | string | The namespace path. |
Returns
string
[]
Defined in
packages/core/src/Namespace.ts:114
get
▸ get<V
>(path
): undefined
| V
Return value for the specified namespace path point or undefined if path is not type of string
Type parameters
Name | Type |
---|---|
V | any |
Parameters
Name | Type | Description |
---|---|---|
path | string | The namespace path to get. |
Returns
undefined
| V
The value at the specified path in the namespace or undefined for any non-string path
Defined in
packages/core/src/Namespace.ts:77
has
▸ has(path
): boolean
Verifies that the specified namespace path point to an existing namespace or terminal value.
Parameters
Name | Type | Description |
---|---|---|
path | string | The namespace path to test. |
Returns
boolean
true
if the namespace or terminal value exists
at the specified path.
Defined in
packages/core/src/Namespace.ts:60
namespace
▸ namespace<V
>(path
): V
Verifies that the specified path in namespace exists, creates it if it does not, and returns the value at the specified path in the namespace.
The method recursively creates all path parts in the namespaces as empty plain objects for all path parts that do not exist yet, including the last one. This means, that if called with a non-existing namespace path as an argument, the return value will be the last created namespace object.
Type parameters
Name | Type |
---|---|
V | any |
Parameters
Name | Type | Description |
---|---|---|
path | string | The namespace path. |
Returns
V
The value at the specified path in the namespace.
Defined in
packages/core/src/Namespace.ts:36
set
▸ set<V
>(path
, value
): void
Set value for the specified namespace path point.
Type parameters
Name |
---|
V |
Parameters
Name | Type | Description |
---|---|---|
path | string | The namespace path to set. |
value | V | - |
Returns
void