Skip to content

Instantly share code, notes, and snippets.

@zzuhan
Last active December 29, 2015 03:49
Show Gist options
  • Save zzuhan/7610237 to your computer and use it in GitHub Desktop.
Save zzuhan/7610237 to your computer and use it in GitHub Desktop.
helper func for exports lib
//
// 适用于node.js,不依赖于其它js,仅是一个库
(function(){
var global = this;
var libName = function () {
}
if(typeof module !== 'undefined') {
module.exports = libName;
} else {
global[libName] = libName;
}
})();
// 适用于依赖于某一个库,或对库进行扩展,如jQuery扩展
// 适用AMD
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
$.fn.jqueryPlugin = function () {};
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment