Created
April 30, 2013 16:11
-
-
Save mweppler/5489730 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do () -> | |
namespacer = (ns, obj) -> | |
if not typeof ns == "string" or not ns.length | |
throw new Error '[namespacer] Invalid namespace' | |
namespace = @ | |
namespace = namespace[part] = namespace[part] or {} for part in ns.split '.' | |
namespace[attr] = obj[attr] for attr of obj if typeof obj == 'object' | |
namespace | |
@['namespacer'] = @['ns'] = namespacer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment