Created
September 19, 2016 17:43
-
-
Save nash403/3758d43a769c7391baef19425fcec85c to your computer and use it in GitHub Desktop.
Simple export function for nodeJS modules meant to be used in the browser
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
function myExport(exported, isDefault, name) { | |
if (!name) throw "myExport function: <name> mustn't be undefined"; | |
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { | |
if (isDefault) { | |
module.exports = exported; | |
} else { | |
module.exports[name] = exported; | |
} | |
} | |
else { | |
window[name] = exported; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment