Skip to content

Instantly share code, notes, and snippets.

@neekey
Created May 21, 2014 06:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neekey/dc0578e4a13166e630d8 to your computer and use it in GitHub Desktop.
Save neekey/dc0578e4a13166e630d8 to your computer and use it in GitHub Desktop.
commonJS for all platform
!(function(){
/**
* 判断当前JS环境
*/
var hasDefine = typeof define === 'function';
var hasExports = typeof module !== 'undefined' && module.exports;
var Mod = function(){
/* write your code */
};
/**
* 根据不同的JS环境输出内容
*/
if( hasExports ){
module.exports = Mod;
}
else if( hasDefine ){
define(function(){
return Mod;
});
}
else {
this.Mod = Mod;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment