Constructor
new Environment(configopt)
Constructor.
This will define the following default properties, if not supplied on the config
argument:
- host
- `data.solarnetwork.net`
- protocol
- `https`
- port
- `443`
These properties correspond to those on the window.location
object when running in a browser. Thus to construct an environment based on the location of the current page you can create an instance like this:
const env = new Environment(window.location);
Name | Type | Attributes | Description |
---|---|---|---|
config | Object | <optional> | an optional set of properties to start with |
- Source
Extends
Methods
enabled(key) → {boolean}
Test if a key is truthy.
Name | Type | Description |
---|---|---|
key | string | the key to test |
- Overrides
- Source
true
if the key is enabled
- Type:
- boolean
toggle(key, enabled) → {module:util~Configuration}
Set or toggle the enabled status of a given key.
If the `enabled` parameter is not passed, then the enabled status will be toggled to its opposite value.
Name | Type | Description |
---|---|---|
key | string | they key to set |
enabled | boolean | the optional enabled value to set |
- Overrides
- Source
this object to allow method chaining
useTls() → {boolean}
Check if TLS is in use via the https
protocol.
- Source
true
if the protocol
is set to https
- Type:
- boolean
value(key, newValueopt) → {object}
Get or set a configuration value.
Name | Type | Attributes | Description |
---|---|---|---|
key | string | The key to get or set the value for | |
newValue | object | <optional> | If defined, the new value to set for the given |
- Overrides
- Source
If called as a getter, the associated value for the given key
, otherwise this object.
- Type:
- object
values(newMapopt) → {object}
Get or set multiple properties.
Name | Type | Attributes | Description |
---|---|---|---|
newMap | object | <optional> | a map of values to set |
- Overrides
- Source
if called as a getter, all properties of this object copied into a simple object; otherwise this object
- Type:
- object