123456 |
- /*!
- * extend-promise v0.0.6
- * Homepage https://github.com/cnwhy/extend-promise#readme
- * License BSD-2-Clause
- */
- !function e(r,n,t){function o(f,u){if(!n[f]){if(!r[f]){var c="function"==typeof require&&require;if(!u&&c)return c(f,!0);if(i)return i(f,!0);throw new Error("Cannot find module '"+f+"'")}var s=n[f]={exports:{}};r[f][0].call(s.exports,function(e){var n=r[f][1][e];return o(n?n:e)},s,s.exports,e,r,n,t)}return n[f].exports}for(var i="function"==typeof require&&require,f=0;f<t.length;f++)o(t[f]);return o}({1:[function(e,r,n){!function(e,r){if("function"==typeof define&&(define.amd||define.cmd))define([],r);else if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("加载 "+e+" 模块失败!,请检查您的环境!")}("extendPromise",function(){var r="undefined"!=typeof window?window:self;if("function"!=typeof r.Promise)throw Error('需要Promise,但未找到,请尝试使用"promise-full.js"');var n=e("../src/polyfills")(r.Promise);return n})},{"../src/polyfills":4}],2:[function(e,r,n){"use strict";function t(e,r,n){function t(e){if(i(n)){for(var r=!1,t=0;t<n.length;t++)if(n[t]==e){r=!0;break}if(!r)return!1}return!h||!u(d[e])}function o(e,r){return f(r)||(r=+r>0?+r:0),function(n){var t,o=d.defer(),u=0,s=function(i){var c=n[i];d.resolve(c).then(function(n){"undefined"!=typeof r?t.push(n):t[i]=n,(0==--u||!e&&r&&t.length>=r)&&o.resolve(t)},function(e){f(r)?o.reject(e):0==--u&&o.resolve(t)}),u++};if(i(n)){t=[],0==n.length&&o.resolve(t);for(var l=0;l<n.length;l++)s(l)}else if(e&&c(n)){var a=0;t={};for(var l in n)s(l),a++;0==a&&o.resolve(t)}else o.reject(new TypeError("参数错误"));return o.promise}}function l(e){for(var r=d.defer(),n=0;n<e.length;n++)!function(){var t=n,o=e[t];d.resolve(o).then(function(e){r.resolve(e)},function(e){r.reject(e)})}();return r.promise}function a(e){return function(r,n){return r?e.reject(r):void e.resolve(n)}}function p(e){var r=this===d?null:this,n=d.defer(),t=s(arguments,1);return t.push(a(n)),e.apply(r,t),n.promise}var d,h;if(r?(h=!0,d=r):d=e,d.Promise||e==r||(d.Promise=e),u(e)&&u(e.prototype.then))d.defer=function(){var r,n,t=new e(function(e,t){r=e,n=t});return{promise:t,resolve:r,reject:n}};else if(u(e.defer))d.defer=function(){return e.defer()};else{if(!u(e.deferred))throw new TypeError("此类不支持扩展!");d.defer=function(){return e.deferred()}}return t("delay")&&(d.delay=function(e,r){var n=d.defer();return setTimeout(function(){n.resolve(r)},e),n.promise}),t("resolve")&&(d.resolve=function(e){var r=d.defer();return r.resolve(e),r.promise}),t("reject")&&(d.reject=function(e){var r=d.defer();return r.reject(e),r.promise}),t("all")&&(d.all=o()),t("allMap")&&(d.allMap=o(!0)),t("some")&&(d.some=function(e,r){return r=+r>=0?+r:0,o(!1,r)(e)}),t("map")&&(d.map=function(e,r,n){function t(){if(c<s.length){var n=s[c],u=d.resolve(r(e[n],n,e)).then(function(e){return t(),e},o.reject);i.push(u),f--,c++}else d.all(i).then(o.resolve,o.reject)}var o=d.defer(),i=[],f=n?+n.concurrency:0;if(0==f||f!=f){for(var u in e)i.push(r(e[u],u,e));return d.all(i).then(o.resolve,o.reject),o.promise}var c=0,s=function(){var r=[];for(var n in e)r.push(n);return r}();do t();while(f>0&&c<s.length);return o.promise}),t("race")&&(d.race=l),t("any")&&(d.any=l),t("nfcall")&&(d.nfcall=p),t("nfapply")&&(d.nfapply=function(e,r){var n=this===d?null:this,t=d.defer();if(!i(r))throw TypeError('"args" is not Array');return r.push(a(t)),e.apply(n,r),t.promise}),d.denodeify=function(e){var r=this===d?null:this;return function(){return p.apply(r,[].concat([e],s(arguments)))}},d}var o=e("./utils"),i=o.isArray,f=o.isEmpty,u=o.isFunction,c=o.isPlainObject,s=o.arg2arr;r.exports=t},{"./utils":5}],3:[function(e,r,n){function t(e){var r=e.prototype;return r.done=function(e,r){this.then(function(r){"function"==typeof e&&setTimeout(function(){e(r)},0)},function(e){"function"==typeof r?setTimeout(function(){r(e)},0):setTimeout(function(){throw e},0)})},r.spread=function(e,r){return this.then(function(r){return e.apply(null,r)},r)},r.fail=r.catch=function(e){return this.then(null,e)},r.catchOf=function(e,r){return r=r||e,this.then(null,function(n){var t=typeof r;if("function"!=t)throw n;if(e===r)return r(n);if(e===n||"function"==typeof e&&n instanceof e)return r(n);throw n})},r.error=function(e){return this.catchOf(Error,e)},r.fin=r.finally=function(e){var r=function(r,n){try{e(r,n)}catch(e){}};return this.then(function(e){return r(e),e},function(e){throw r(null,e),e})},e}r.exports=t},{}],4:[function(e,r,n){r.exports=function(r){return e("../src/extendClass")(r),e("../src/extendPrototype")(r),r}},{"../src/extendClass":2,"../src/extendPrototype":3}],5:[function(e,r,n){"use strict";n.isPlainObject=function(e){return null!==e&&"object"==typeof e&&!e.nodeType&&e!==e.window&&!(e.constructor&&!Object.prototype.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))},n.isArray=function(e){return"[object Array]"==Object.prototype.toString.call(e)},n.isFunction=function(e){return"function"==typeof e},n.isEmpty=function(e){return"undefined"==typeof e||null===e},n.arg2arr=function(e,r,n){return Array.prototype.slice.call(e,r,n)}},{}]},{},[1]);
|