 <p>Is this some kind of weird code-golf?</p> <p>Try this, it might work...</p> <pre><code>dpcom.library = function(name, func) { var p = name.split('.'), e, root = this; while (e = p.shift()) root = root[e] = root[e] || (!p.length ? func : {}); } </code></pre>