Last active
August 29, 2015 14:10
-
-
Save binzeehale/0598756042175d4ef0c6 to your computer and use it in GitHub Desktop.
The write way for require/common/globally javascript lib
This file contains hidden or 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
(function(name, definition) { | |
if (typeof module != 'undefined') module.exports = definition(); | |
else if (typeof define == 'function' && typeof define.amd == 'object') define(definition); | |
else this[name] = definition(); | |
}('mod', function() { | |
//This is the code you would normally have inside define() or add to module.exports | |
return { | |
sayHi: function(name) { | |
console.log('Hi ' + name + '!'); | |
} | |
}; | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment