lib/utils.js
function setPropertyVal (pObj, pProp, pNewVal) {
    if (typeof pProp === 'string') {
        pProp = pProp || '';
        pProp = pProp.split('.');
    }

    if (pProp.length > 1) {

        var prop    = pProp.shift();

        pObj[prop]  = (typeof pObj[prop] !== 'undefined'
                       || typeof pObj[prop] !== 'null') ? pObj[prop] : {};

        setPropertyVal(pObj[prop], pProp, pNewVal);

    } else {
        pObj[ pProp[0] ] = pNewVal;
    }
}
function setPropertyVal (pObj, pProp, pNewVal) {
    if (typeof pProp === 'string') {
        pProp = pProp || '';
        pProp = pProp.split('.');
    }

    if (pProp.length > 1) {

        var prop    = pProp.shift();

        pObj[prop]  = (typeof pObj[prop] !== 'undefined'
                       || typeof pObj[prop] !== 'null') ? pObj[prop] : {};

        setPropertyVal(pObj[prop], pProp, pNewVal);

    } else {
        pObj[ pProp[0] ] = pNewVal;
    }
}
function setPropertyVal ( pObj , pProp , pNewVal ) { if ( typeof pProp === 'string' ) { pProp = pProp || '' ; pProp = pProp . split ( '.' ) ; } if ( pProp . length > 1 ) { var prop = pProp . shift ( ) ; pObj [ prop ] = ( typeof pObj [ prop ] !== 'undefined' || typeof pObj [ prop ] !== 'null' ) ? pObj [ prop ] : { } ; setPropertyVal ( pObj [ prop ] , pProp , pNewVal ) ; } else { pObj [ pProp [ 0 ] ] = pNewVal ; } }
Utility method to set property value of an object by using the dot notation of the affected property

For instance, for the following object:
var someObject =
{
animals: {
cow: true,
cat: false
}
};

If we want to change the property val of 'cat', we can use this function to do so:

setPropertyVal (someObject, 'animals.cat', true);

@param pObj Object whose property value needs to be updated
@param pProp dot notation property value, e.g. 'animal.cat'
@param pNewVal new value with which the property @param pProp will be updated with
Utility method to set property value of an object by using the dot notation of the affected property