Class

Environment

Environment(initialDataopt)

Constructor

# new Environment(initialDataopt)

Manages environment-related data and provides methods for accumulation and key retrieval.

A class representing an environment with accumulation capabilities.

Parameters:
Name Type Attributes Description
initialData T <optional>

The initial data to populate the environment with.

View Source utils/environment.ts, line 5

Extends

  • ObjectAccumulator.<T>

Members

# protected factory

Defines how new instances of the Environment class should be created.

A factory function for creating Environment instances.

View Source utils/environment.ts, line 21

EnvironmentFactory.<any, any>

# protected static factory

Defines how new instances of the Environment class should be created.

A factory function for creating Environment instances.

View Source utils/environment.ts, line 126

Methods

# protected expand(value) → {void}

Defines properties on the environment object that can be accessed as getters and setters

Expands an object into the environment

Parameters:
Name Type Description
value V

The object to expand into the environment

View Source utils/environment.ts, line 154

void

# protected fromEnv(k) → {unknown}

Gets a value from the environment variables, handling browser and Node.js environments differently

Retrieves a value from the environment

Parameters:
Name Type Description
k string

The key to retrieve from the environment

View Source utils/environment.ts, line 144

The value from the environment, or undefined if not found

unknown

# static accumulate(value) → {V}

Adds new properties to the environment from the provided object.

Accumulates the given value into the environment.

Parameters:
Name Type Description
value V

The object to accumulate into the environment.

View Source utils/environment.ts, line 176

The updated environment instance.

V

# protected static instance(…args) → {E}

Ensures only one instance of the Environment class exists.

Retrieves or creates the singleton instance of the Environment class.

Parameters:
Name Type Attributes Description
args Array.<unknown> <repeatable>

Arguments to pass to the factory function if a new instance is created.

View Source utils/environment.ts, line 166

The singleton instance of the Environment class.

E

# static keys(toEnvopt) → {Array.<string>}

Gets all keys in the environment, with an option to format them for environment variables.

Retrieves the keys of the environment, optionally converting them to ENV format.

Parameters:
Name Type Attributes Default Description
toEnv boolean <optional>
true

Whether to convert the keys to ENV format.

View Source utils/environment.ts, line 185

An array of keys from the environment.

Array.<string>