Confippet's config is store in an object that contains two special hidden properties $
and _$
.
Example to create a new store:
const Confippet = require("electrode-confippet");
const store = Confippet.store(); // creates a new store
The preset config is a store object:
const config = require("electrode-confippet").config;
const url = config.$("service.url");
$
is a function that allows you to retrieve config with a string or array path.
For example, instead of doing:
const url = config.service && config.service.url;
You can do:
const url = config.$("service.url");
_$
is an object with these methods.
Directly override existing config with data
.
Example:
config._$.use({ url: "http://localhost"});
Will change config.url
to http://localhost
.
Directly use data
as defaults for the config.
Example:
config._$.defaults({ url: "http://localhost" });
Will set config.url
to http://localhost
if it's undefined
.
Load and add config using composeConfig.
Example:
config._$.compose(composeOptions);
Set config to {}