Code coverage report for object/namespace.js

Statements: 100% (11 / 11)      Branches: 100% (4 / 4)      Functions: 100% (4 / 4)      Lines: 100% (9 / 9)     

All files » object/ » namespace.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 201         1 9 6 10 6   10   6     1      
define(['../array/forEach'], function (forEach) {
 
    /**
     * Create nested object if non-existent
     */
    function namespace(obj, path){
        if (!path) return obj;
        forEach(path.split('.'), function(key){
            if (!obj[key]) {
                obj[key] = {};
            }
            obj = obj[key];
        });
        return obj;
    }
 
    return namespace;
 
});