Configuration store for Node.js applications.
Installing
npm add aldo-config
Testing
npm test
Usage
const Store = // create a new store with initial valuesconst config = foo: 'bar' console//=> 'bar' configconsole//=> true // Use dot-notation to access nested propertiesconfigconsole//=> {baz: true} console//=> { "foo": "bar", "awesome": true, "bar": { "baz": true } }
API
config.set(key, value)
Set an item.
config.get(key, [defaultValue])
Get an item, or defaultValue
if undefined.
config.has(key)
Check if an item exists.
config.merge(values)
Merge old values with the new ones.
Will set plain values and merge objects and arrays.
config.enable(key)
Set an item value to true
.
If the key points to an object, a property
enabled
will be added withtrue
value.
config.enabled(key)
Check whether a key's value is truthy.
config.disable(key)
Set an item value to false
.
If the key points to an object, a property
enabled
will be added withfalse
value.
config.enabled(key)
Check whether a key's value is falsy.