Created
January 23, 2012 15:00
-
-
Save cajones/1663536 to your computer and use it in GitHub Desktop.
Possible module boilerplate for AMD, CommonJS and namespace methods
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
var library = | |
function(container) { | |
var stringify = function(obj, rootName) { | |
/* implementation goes here */ | |
}; | |
container.stringify = stringify; | |
return container; | |
}; // define the library in a function, injecting external dependencies if needed | |
var useAMD = typeof define === "function", | |
root = this; | |
if (typeof exports === 'undefined') { | |
root.JSONX = root.JSONX || {}; | |
} | |
if (useAMD) { | |
define('./jsonx', function() { | |
return library(root.JSONX || exports); | |
}); | |
} else { | |
library(root.JSONX || exports); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment