Manage configuration objects with ease.
npm install @specla/config
import Config from '@specla/config'
const config = new Config({
'my.config.key': 'some value...'
})
// Access property in the config
config.get('my.config.key') // returns 'some value...'
// Access part of config property
config.get('my') // returns { config: { key: 'some value...' } }
// Set or update a config property value
config.set('my.config.key', 'updated value...')
// Delete a config property
config.unset('my.config.key')
// Merge current config with new config
config.merge({
'my.config.newKey': 'other key...'
})
Specla config ships with functional properties which is a dynamic property that has a relation to an other config property.
const config = new Config({
'normal.prop': 'test',
'func.prop': config => config.get('normal.prop') + ' functional property'
})
config.get('func.prop') // will return "test functional property"