kitty-config
What is this?
kitty-config is a very simple multi-file configuration manager inspired by config.
Quick Start
Install in your app directory
$ npm install kitty-config
Create default file config/config.json
{
"app" : {
"port" : 3000,
"options" : {
"keepAlive" : true
}
},
"things" : ["one", "two", "three"],
"string" : "{ \"cat\" : \"fish\" }"
}
Basic usage
var KittyConfig = require('kitty-config');
var config = KittyConfig();
config.get('app.port'); // 3000
config.get('things')[2]; // three
config.parse('string'); // { "cat" : "fish" }
config.parse('string', 'cat'); // fish
config.stringify('app.options'); // "{"keepAlive":true}"
config.keys('app'); // ["port", "options"]
config.values('app'); // [3000, { "keepAlive" : true }]
config.get('invalid.value'); // undefined
Options
-
path - Location of config file
- default - config/config.json
-
splitter - Character to split at when searching multiple levels
- default -
.
- default -
var config = KittyConfig('config/development.json');
config.get('app/port');
Multiple Configuration files
var userSettings = KittyConfig('config/user_settings.json');
var chatSettings = KittyConfig('config/chat_settings.json');
userSettings.get('foo.bar');
chatSettings.get('baz.qux');
Access entire object
var config = KittyConfig();
console.log( config.data );
Additional Notes
- KittyConfig will load the file every time
._get
is called. You will not need to restart the app to apply changes to a configuration file - Please report any issues here