Skip to main content

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

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

NameType
Vany

Parameters

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

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

NameType
Vany

Parameters

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

NameTypeDescription
pathstringThe namespace path to set.
valueV-

Returns

void

Defined in

packages/core/src/Namespace.ts:99