//压缩迷你
! function(a) {
"use strict";
function test() {
return "Hello World!"
}
"function" == typeof define && define.amd ? define(function() {
return test
}) : "object" == typeof module && module.exports ? module.exports = test : a.hello = test
}(this);
//实例:
//var ok = require('assets/js/***.js');
// console.log(ok.hello());
//输出:Hello World!
//简化
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory;
} else {
root.dchart = factory;
}
}(this, function() {
function dchart(a) {
}
return dchart;
}));
//UMD模式之 AMD,Node,Browser globals 常用
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(factory);
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.test = factory();
}
}(this, function() {
function test() {
console.log('hello World');
}
return test;
}));
//UMD模式之 AMD,Node,Browser globals 常用二 简化
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.test = factory());
}(this, (function () { 'use strict';
return test;
})));