Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yuya/5370885 to your computer and use it in GitHub Desktop.
Save yuya/5370885 to your computer and use it in GitHub Desktop.
それっぽいやつ
do (root = this, factory = (window, document) ->
NS = "Hoge"
class Hoge
constructor: ->
@hoge = "hoge"
window[NS] = Hoge
) ->
# AMD
if typeof define is "function" and define.amd is "object"
define(NS, [], ->
factory(root, root.document)
root[NS]
)
# Browser global scope
else
factory(root, root.document)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment