| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1 1 9 6 10 6 10 6 1 | define(['../array/forEach'], function (forEach) {
/**
* Create nested object if non-existent
* @version 0.1.0 (2012/01/30)
*/
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;
});
|