Last active
June 21, 2017 07:11
-
-
Save kioku-systemk/7801c591e81ef8ef20958aaed6e4ef30 to your computer and use it in GitHub Desktop.
js module definition
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
// UMD (Universal Module Definition) | |
(function(global, factory, name) { | |
if (typeof define === 'function' && define.amd) { define([], factory); /* AMD*/ } | |
else if (typeof exports === 'object') { module.exports = factory(); /* CommonJS */ } | |
else { global[name] = factory(); /* Global*/ } | |
})(this, function() { | |
'use strict'; | |
var MyClass = { | |
hoge: function () { | |
console.log('test'); | |
} | |
} | |
return MyClass; | |
}, "MyClass"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使うときは、
var MyClass = MyClass || require('./myclass');
MyClass.hoge();