# 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. |
Extends
- ObjectAccumulator.<T>
Members
# protected factory
Defines how new instances of the Environment class should be created.
A factory function for creating Environment instances.
EnvironmentFactory.<any, any>
# protected static factory
Defines how new instances of the Environment class should be created.
A factory function for creating Environment instances.
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 |
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 |
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. |
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. |
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. |
An array of keys from the environment.
Array.<string>