Last active
December 29, 2015 03:49
-
-
Save zzuhan/7610237 to your computer and use it in GitHub Desktop.
helper func for exports lib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 适用于node.js,不依赖于其它js,仅是一个库 | |
(function(){ | |
var global = this; | |
var libName = function () { | |
} | |
if(typeof module !== 'undefined') { | |
module.exports = libName; | |
} else { | |
global[libName] = libName; | |
} | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 适用于依赖于某一个库,或对库进行扩展,如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