Constructor
new Opts(…sources)
Build an Opts instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
sources |
object |
<repeatable> |
Initial sources of options. The order of sources matters, as the ones added later will override the ones added earlier. Keep that in mind when adding sources. |
Methods
_err(msg, info, errClassopt) → {object}
Handle an error
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
msg |
string | A summary of the error. |
||
info |
object | Debugging information for the logs. |
||
errClass |
function |
<optional> |
TypeError | Constructor for an |
Throws:
-
An error of
errClass
class, if fatal mode is enabled. - Type
- Error
Returns:
this
- Type
- object
add(…sources) → {object}
Add new sources of options.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
sources |
object | string |
<repeatable> |
Sources and positions. If this is an If this is a |
Returns:
this
- Type
- object
at(pos) → {object}
Set the position/offset to add new sources at.
This will affect subsequent calls to the add()
method.
Parameters:
Name | Type | Description |
---|---|---|
pos |
number | The position/offset value.
The default value if none is specified is |
Throws:
-
An invalid value was passed while
fatal
was true. - Type
- TypeError
Returns:
this
- Type
- object
clear() → {object}
Remove all current sources. Resets compiled options data.
Returns:
this
- Type
- object
fatal(val) → {object}
Set the fatal error handling setting.
Default is false
, so errors will be logged, but not thrown.
Parameters:
Name | Type | Description |
---|---|---|
val |
boolean | Should errors be fatal? |
Returns:
this
- Type
- object
from(source) → {object}
Set the object to look for nested properties in.
This will affect subsequent calls to the add()
method.
Parameters:
Name | Type | Description |
---|---|---|
source |
object | number | boolean | Source definition
If this is not specified, then it defaults to |
Throws:
-
An invalid value was passed while
fatal
was true. - Type
- TypeError
Returns:
this
- Type
- object
get(opt, argsopt) → {*}
Get an option value from our compiled data sources.
This uses the get()
function, but instead of using positional
arguments, it supports an object of named options instead.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
string | The name of the option to get. |
|||||||||||||||||||||||||||||||
args |
object |
<optional> |
Optional arguments for Properties
|
Returns:
The output of the get()
function.
- Type
- *
remove(…sources) → {object}
Remove existing sources of options.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
sources |
object |
<repeatable> |
Sources to remove. |
Returns:
this
- Type
- object
strict(val) → {object}
Set the strict property check setting.
Default is false
, we don't care about non-existent properties.
Parameters:
Name | Type | Description |
---|---|---|
val |
boolean | Should non-existant properties be an error? |
Returns:
this
- Type
- object