Skip to content

Instantly share code, notes, and snippets.

@nash403
Created September 19, 2016 17:43
Show Gist options
  • Save nash403/3758d43a769c7391baef19425fcec85c to your computer and use it in GitHub Desktop.
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
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