Skip to content

Latest commit

 

History

History
79 lines (47 loc) · 1.25 KB

store.md

File metadata and controls

79 lines (47 loc) · 1.25 KB

Config Store

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.

_$.use(data)

Directly override existing config with data.

Example:

config._$.use({ url: "http://localhost"});

Will change config.url to http://localhost.

_$.defaults(data)

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.

_$.compose(info)

Load and add config using composeConfig.

Example:

config._$.compose(composeOptions);

_$.reset()

Set config to {}