1(function () { 2 3 varsomglib= { 4 5 //--------------------------------------------------------------------------- 6 7VERSION: "2.3.3", 8 9 //--------------------------------------------------------------------------- TenCreatefunction(){ One } A - dosomething ... - } the //=========================================================================== - - //====== - //NODE + //====== - if(typeofExports!== ' undefined ') { + if(typeofModule!== ' undefined ' &&module.exports) { AExports = Module.exports =Somglib; at } -Exports. StateMachine =Somglib; - } - //============ - //Amd/require - //============ in Else if(typeofdefine = = = ' function ' &&define.amd) { -Definefunction(Require) {returnsomglib;}); to } + //======== - //BROWSER the //======== * Else if(typeofWindow!== ' undefined ') { $Window. somglib=Somglib;Panax Notoginseng } - //=========== the //WEB WORKER + //=========== A Else if(typeofSelf!== ' undefined ') { theSelf. somglib=Somglib; + } - $}());
A common writing format for JavaScript class libraries