lib/object.js
function deepSet(parent, key, value, mode) {
    // if(typeof value==='string') value = value.replace(/(\r\n|\r|\n)\s*$/, ''); // replace line endings and white spaces
    var parts = key.split('.');
    var current = parent;
    if(key==='this') {
        if(mode==='push') parent.push(value);
        else parent = value.toString();
    }
    else {
        for(var i=0; i<parts.length; i++) {
            if(i >= parts.length-1) {
                if(mode==='push') current[parts[i]].push(value);
                else current[parts[i]] = value;
            }
            else current[parts[i]] = current[parts[i]] || {};    
            current = current[parts[i]];
        }
    }
    return parent;
}
function deepSet(parent, key, value, mode) {
    // if(typeof value==='string') value = value.replace(/(\r\n|\r|\n)\s*$/, ''); // replace line endings and white spaces
    var parts = key.split('.');
    var current = parent;
    if(key==='this') {
        if(mode==='push') parent.push(value);
        else parent = value.toString();
    }
    else {
        for(var i=0; i<parts.length; i++) {
            if(i >= parts.length-1) {
                if(mode==='push') current[parts[i]].push(value);
                else current[parts[i]] = value;
            }
            else current[parts[i]] = current[parts[i]] || {};    
            current = current[parts[i]];
        }
    }
    return parent;
}
function deepSet ( parent , key , value , mode ) { // if(typeof value==='string') value = value.replace(/(\r\n|\r|\n)\s*$/, ''); // replace line endings and white spaces var parts = key . split ( '.' ) ; var current = parent ; if ( key === 'this' ) { if ( mode === 'push' ) parent . push ( value ) ; else parent = value . toString ( ) ; } else { for ( var i = 0 ; i < parts . length ; i ++ ) { if ( i >= parts . length - 1 ) { if ( mode === 'push' ) current [ parts [ i ] ] . push ( value ) ; else current [ parts [ i ] ] = value ; } else current [ parts [ i ] ] = current [ parts [ i ] ] || { } ; current = current [ parts [ i ] ] ; } } return parent ; }
Define cascading props in objects in namespace separated by dot,
if props are on lower level, it will create empty object
@param {Object} parent base object where you want add props
@param {String} namespace dot separated
@param {Object} value value to add to object prop
@param {String} mode if "push", it will add value to array
@returns {Object}  parent object after properties are added
Define cascading props in objects in namespace separated by dot if props are on lower level it will create empty object