key-value-conf is a simple, lightweight and persistent node.js module. Some of its features are:
- One multi-leveled selector.
- Evented control of changes.
- Persistent config file.
- Restriction policies for changes.
0.9.3
var Config = require('key-value-conf');
conf = new Config();
conf.get();
// { foo: 'bar' }
conf.set('myConfig', {
key1: 'value1',
key2: 'value2',
key3: 'value3'
});
conf.set('myOtherConfig', {
key1: 'value1',
key2: [1,2,3],
key3: {
key4: true,
key5: new Date()
}
});
conf.get('myOtherConfig.key1');
// 'value1'
conf.get('myOtherConfig.key3.key4')
// true
conf.get('myOtherConfig.key2');
// [ 1, 2, 3 ]
conf.on('myConfig.key1', function(selector, value) {
console.log('[changes] Key ', selector, 'now is:', value);
});
conf.on('myOtherConfig.*', function(selector, value) {
console.log('Something has changed in myOtherConfig!');
});
conf.on(['persist', 'reload', 'location'], function(config) {
console.log('Check out current config:', config);
});
conf.isPersisted();
// false
conf.getLocation();
// '~/dev/node_modules/key-value-conf/default.conf.json'
conf.setLocation('/tmp/test.conf.json');
conf.persist();
- default
true
- Description
- default
true
- Description
- default
false
- Description
- default
'.'
- Description
- default
'utf-8'
- Description
- default
33
- Description
- default
true
- Description
Description
Description
Description
Description
Description
Description
Description
Description
Description