Skip to content

Instantly share code, notes, and snippets.

@markdaws
Created February 7, 2012 05:18
Show Gist options
  • Save markdaws/1757378 to your computer and use it in GitHub Desktop.
Save markdaws/1757378 to your computer and use it in GitHub Desktop.
Example of how to share JavaScript between client and node.js
function(exports) {
if(!exports) {
// This is client side code
window.MyApp = window.MyApp = window.MyApp || {};
exports = window.MyApp.common = window.MyApp.common || {}
}
exports.foo = function() {
return 'bar';
};
})((typeof process === 'undefined') || !process.versions ? null : exports);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment