[!!!] The source code of this package is on https://github.com/docomodigital/js-utils, this repository will be removed asap
Simple library to get config value from a given object, supports nested values.
import Config from '@docomodigital/js-config';
const configObject = {
host: 'https://example.com',
api: {
version: 'v1',
routes: {}
},
foo: {
bar: 'test'
}
}
Config.init({
config: configObject,
});
Config.get('api.version'); // 'v1'
Config.get('foo'); // { bar: 'test' }
If Config is initialized with the flag upperCase: true
, the keys are searched in uppercase:
Config.init({
config: { KEY: 'value' },
upperCase: true
});
Config.get('key'); // 'value'
npm install --save @docomodigital/js-config
To read documentation, go to:
http://docomodigital.github.io/js-config/latest
or run the following command inside the js-config folder:
npm run doc:open