sjl.js
function autoNamespace (ns_string, objToSearch, valueToSet) {
        //throwTypeErrorIfNotOfType('sjl', 'autoNamespace', 'ns_string', ns_string, String);
        var parent = objToSearch,
            shouldSetValue = !isUndefined(valueToSet),
            classOfObjToSearch = classOf(objToSearch);
        if (classOfObjToSearch !== _Object && objToSearch instanceof Function === false) {
            throw new TypeError ('sjl.autoNamespace expects a Constructor or an instance obj to search on.' +
                'Value received: `' + classOfObjToSearch + '`.');
        }
        ns_string.split('.').forEach(function (part, index, parts) {
            if (part in parent === false || isUndefined(parent[part])) {
                parent[part] = {};
            }
            if (index === parts.length - 1 && shouldSetValue) {
                parent[part] = valueToSet;
            }
            parent = parent[part];
        });
        return parent;
    }
function autoNamespace (ns_string, objToSearch, valueToSet) {
        //throwTypeErrorIfNotOfType('sjl', 'autoNamespace', 'ns_string', ns_string, String);
        var parent = objToSearch,
            shouldSetValue = !isUndefined(valueToSet),
            classOfObjToSearch = classOf(objToSearch);
        if (classOfObjToSearch !== _Object && objToSearch instanceof Function === false) {
            throw new TypeError ('sjl.autoNamespace expects a Constructor or an instance obj to search on.' +
                'Value received: `' + classOfObjToSearch + '`.');
        }
        ns_string.split('.').forEach(function (part, index, parts) {
            if (part in parent === false || isUndefined(parent[part])) {
                parent[part] = {};
            }
            if (index === parts.length - 1 && shouldSetValue) {
                parent[part] = valueToSet;
            }
            parent = parent[part];
        });
        return parent;
    }
function autoNamespace ( ns_string , objToSearch , valueToSet ) { //throwTypeErrorIfNotOfType('sjl', 'autoNamespace', 'ns_string', ns_string, String); var parent = objToSearch , shouldSetValue = ! isUndefined ( valueToSet ) , classOfObjToSearch = classOf ( objToSearch ) ; if ( classOfObjToSearch !== _Object && objToSearch instanceof Function === false ) { throw new TypeError ( 'sjl.autoNamespace expects a Constructor or an instance obj to search on.' + 'Value received: `' + classOfObjToSearch + '`.' ) ; } ns_string . split ( '.' ) . forEach ( function ( part , index , parts ) { if ( part in parent === false || isUndefined ( parent [ part ] ) ) { parent [ part ] = { } ; } if ( index === parts . length - 1 && shouldSetValue ) { parent [ part ] = valueToSet ; } parent = parent [ part ] ; } ) ; return parent ; }
Takes a namespace string and fetches that location out from
an object/Map.  If the namespace doesn't exists it is created then
returned.  Also allows you to set a value at that namespace (last parameter).
@example
// will create/fetch within `obj`: hello: { world: { how: { are: { you: { doing: {} } } } } }
autoNamespace ('hello.world.how.are.you.doing', obj)

@example
// Will set 'hello.what.is.your.name' to 'juan'
autoNamespace ('hello.what.is.your.name', obj, 'juan')

@function module:sjl.autoNamespace
@param ns_string {String} - The namespace you wish to fetch
@param objToSearch {Object} - The object to search for namespace on
@param valueToSet {Object} - Optional.  A value to set on the key (last key if key string (a.b.c.d = value)).
@note For just checking the namespace and not creating it, use `searchObj` instead.
@returns {Object}
Takes a namespace string and fetches that location out from an object / Map . If the namespace doesn t exists it is created then returned . Also allows you to set a value at that namespace ( last parameter ) . @example // will create / fetch within obj : hello : { world : { how : { are : { you : { doing : {} } } } } } autoNamespace ( hello . world . how . are . you . doing obj )