Skip to content

Instantly share code, notes, and snippets.

@indutny
Created May 10, 2011 11:26
Show Gist options
  • Save indutny/964299 to your computer and use it in GitHub Desktop.
Save indutny/964299 to your computer and use it in GitHub Desktop.
function thatYouWantToExport() {
};
if (typeof exports === 'undefined') {
window.myFn = thatYouWantToExport;
} else {
exports.myFn = thatYouWantToExport;
}
@heapwolf
Copy link

if you come up with a clever way to not use | this | let me know ;)

@indutny
Copy link
Author

indutny commented May 10, 2011

this.exports || this === (typeof exports === 'undefined' ? window : exports)

@heapwolf
Copy link

hehe, my original code is looking pretty good at this point ;)

@indutny
Copy link
Author

indutny commented May 10, 2011

Your truth :) Just like my code more than yours :D

@heapwolf
Copy link

hehe, thats how it is, everyone prefers their own code ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment