Last active
August 29, 2015 13:56
-
-
Save jeshuamaxey/8830600 to your computer and use it in GitHub Desktop.
Pop this at the end of your node module and it can be used equally well in a browser too
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
/* | |
* all credit to @matteoagosti | |
* http://www.matteoagosti.com/blog/2013/02/24/writing-javascript-modules-for-both-browser-and-node/ | |
*/ | |
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { | |
//export for node | |
module.exports = /*MODULE_OBJECT*/ ; | |
} | |
else { | |
//export for browser | |
window./*MODULE_OBJECT*/ = /*MODULE_OBJECT*/; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment