src/config-manager.js
function (key) {
        'use strict';
        var value = conf[key];
        if (!isStr(key)) {
            throw new Error(confKeyStrMsg, 'config-manager');
        }
        if (key.indexOf('.') !== -1) {
            value = getNestedValue(conf, key);
        }
        if (isObj(value)) {
            if (isExtensionObj(value)) {
                value = applyExtension.call(this, value);
            } else {
                value = openReferences.call(this, value);
                value = JSON.parse(JSON.stringify(value));
            }
        }
        return value;
    }
function (key) {
        'use strict';
        var value = conf[key];
        if (!isStr(key)) {
            throw new Error(confKeyStrMsg, 'config-manager');
        }
        if (key.indexOf('.') !== -1) {
            value = getNestedValue(conf, key);
        }
        if (isObj(value)) {
            if (isExtensionObj(value)) {
                value = applyExtension.call(this, value);
            } else {
                value = openReferences.call(this, value);
                value = JSON.parse(JSON.stringify(value));
            }
        }
        return value;
    }
function ( key ) { 'use strict' ; var value = conf [ key ] ; if ( ! isStr ( key ) ) { throw new Error ( confKeyStrMsg , 'config-manager' ) ; } if ( key . indexOf ( '.' ) !== - 1 ) { value = getNestedValue ( conf , key ) ; } if ( isObj ( value ) ) { if ( isExtensionObj ( value ) ) { value = applyExtension . call ( this , value ) ; } else { value = openReferences . call ( this , value ) ; value = JSON . parse ( JSON . stringify ( value ) ) ; } } return value ; }
Get 'value' of 'key'.
@param {string} key - key in configuration. Like 'simpleKey' or 'section.subsection.complex.key'. See config-managet-test.js
@returns {*} value - `value` of `key`. Can be `primitive` or `javascript object`. Objects not connected to original configuration.
If value contain reference (`{$ref: 'some.reference.to.other.key'}`), then return reference value,
if value contain reference with template(`{ $ref: 'some.reference', $tmpl: '{some}:{template}.{string}' }`)
and reference point to object then return string with populated placeholder in template (look example on top of page).
@example <caption>Using deep references</caption>
```js
// Configuration example
{
nameValue: 'loginName',
dbParams: {
username: { $ref: 'web.nameValue' },
password: '12345'
},
dbConnection: {
user: { $ref: 'web.dbParams' },
key: { $ref: 'web.sessionKey' }
},
dbConectionStr: {
$ref: 'web.dbConnection',
$tmpl: 'db:{user.username}::{user.password}@{key}'
}
};
configManager.get('dbConnection'); //should return object
// {
//   user: {
//       username: 'loginName',
//       password: '12345'
//   },
//   key: '6ketaq3cgo315rk9'
// }
configManager.get('dbConectionStr'); //should return string 'db:loginName::12345@6ketaq3cgo315rk9'
```
Get value of key .