coffee-script 의 namespace
여기에서 namespace 를 사용하는 소스를 제공 해 준다.
# Code: # 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 # Usage: # namespace 'Hello.World', (exports) -> # `exports` is where you attach namespace members exports.hi = -> console.log 'Hi World!' namespace 'Say.Hello', (exports, top) -> # `top` is a reference to the main namespace exports.fn = -> top.Hello.World.hi() # Usage: # class AClass contructor : -> console.log(this) namespace 'MyNameSpace.Somthing', (exports) -> exports.AClass = AClass
댓글 없음:
댓글 쓰기