Last active
December 13, 2015 22:09
-
-
Save bryanberger/4982719 to your computer and use it in GitHub Desktop.
Simple Module Export - Supports require.js defining of jQuery into the module.
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
// | |
// more documentation on the module pattern here: http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth | |
// | |
(function( factory ) { | |
// if require js is available use it to define jquery and require it. | |
if (typeof define !== 'undefined' && define.amd) { | |
define(['jquery'], factory); | |
} else if (typeof module !== 'undefined' && module.exports) { | |
var jQuery = require('jquery'); | |
module.exports = factory( $ ); | |
} else { | |
window.testframework = factory( $ ); | |
} | |
})(function( $ ) { | |
/* Exported Properties */ | |
var exports = {}; | |
exports.foo = 'bar'; | |
/* Private Methods */ | |
function privateMethod() { | |
console.log('a private method'); | |
} | |
/* Exported Methods */ | |
exports.publicMethod = function() { | |
console.log('a publicly exported method'); | |
} | |
return exports; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment