Skip to content

Instantly share code, notes, and snippets.

@xuanfeng
Created July 13, 2016 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xuanfeng/19b8832d2f69081402b6c6769042e4b0 to your computer and use it in GitHub Desktop.
Save xuanfeng/19b8832d2f69081402b6c6769042e4b0 to your computer and use it in GitHub Desktop.
define module
// js库模版
// 可直接被引用或者AMD、CMD方式加载
;(function(root, factory) {
if (typeof module !== 'undefined' && module.exports) {// CommonJS
module.exports = factory();
} else if (typeof define === 'function' && define.amd) {// AMD / RequireJS
define(factory);
} else {
root.Promise = factory.call(root);
}
}(this, function() {
'use strict';
function Promise(resolver) {
console.log('promise');
return this;
}
Promise.prototype.then = function(resolve, reject) {}
return Promise;
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment