从uuid.js中抽出来的写法。
(function() {
var _global = this;
// Export public API
var obj = {};
obj.attr = function(params){
};
if (typeof define === 'function' && define.amd) {
// Publish as AMD module
define(function() {return obj;});
}
else if (typeof(module) != 'undefined' && module.exports) {
// Publish as commonjs module
module.exports = obj;
}
else {
// Publish as global (in browsers)
var _previousRoot = _global.obj;
// **`noConflict()` - (browser only) to reset global 'obj' var**
obj.noConflict = function() {
_global.obj = _previousRoot;
return obj;
};
_global.obj = obj;
}
}).call(this);