Created
May 24, 2012 12:39
-
-
Save akloboucnik/2781348 to your computer and use it in GitHub Desktop.
CoffeeScript namespace 101
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
namespace = (target, name, block) -> | |
[target, name, block] = [(if typeof exports isnt 'undefined' then exports else window), arguments...] if arguments.length < 3 | |
top = target | |
target = target[item] or= {} for item in name.split '.' | |
block target, top | |
namespace '', (exports, root) -> root.namespace = namespace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment