Created
October 5, 2012 15:37
-
-
Save mikaelbr/3840565 to your computer and use it in GitHub Desktop.
JS Module Template
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 () { | |
var moduleName = 'someName', | |
methods = {}, | |
root = this; | |
// Private methods | |
var _foo = function () { | |
}; | |
// Public methods | |
methods.foo = function () { | |
}; | |
// - From async.js | |
// AMD / RequireJS | |
if (typeof define !== 'undefined' && define.amd) { | |
define(moduleName, [], function () { | |
return methods; | |
}); | |
} | |
// Node.js | |
else if (typeof module !== 'undefined' && module.exports) { | |
module.exports = methods; | |
} | |
// included directly via <script> tag | |
else { | |
root[moduleName] = methods; | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment