extend-promise
Advanced tools
Comparing version 0.0.6 to 0.0.7
/*! | ||
* extend-promise v0.0.6 | ||
* extend-promise v0.0.7 | ||
* Homepage https://github.com/cnwhy/extend-promise#readme | ||
@@ -348,11 +348,9 @@ * License BSD-2-Clause | ||
prototype.fin = | ||
prototype['finally'] = function(fun){ | ||
var run = function(y,n){try{fun(y,n);}catch(e){}} | ||
return this.then(function(data){ | ||
run(data); | ||
return data; | ||
prototype['finally'] = function(fn){ | ||
if(typeof fn !== "function") return this; | ||
return this.then(function(v){ | ||
return Promise.resolve(fn()).then(function(){return v}) | ||
},function(err){ | ||
run(null,err); | ||
throw err; | ||
}) | ||
return Promise.resolve(fn()).then(function(){throw err;}) | ||
}); | ||
} | ||
@@ -359,0 +357,0 @@ return Promise; |
/*! | ||
* extend-promise v0.0.6 | ||
* extend-promise v0.0.7 | ||
* Homepage https://github.com/cnwhy/extend-promise#readme | ||
* License BSD-2-Clause | ||
*/ | ||
!function e(n,r,t){function o(u,f){if(!r[u]){if(!n[u]){var c="function"==typeof require&&require;if(!f&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var s=r[u]={exports:{}};n[u][0].call(s.exports,function(e){var r=n[u][1][e];return o(r?r:e)},s,s.exports,e,n,r,t)}return r[u].exports}for(var i="function"==typeof require&&require,u=0;u<t.length;u++)o(t[u]);return o}({1:[function(e,n,r){!function(e,n){if("function"==typeof define&&(define.amd||define.cmd))define([],n);else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("加载 "+e+" 模块失败!,请检查您的环境!");var r="undefined"!=typeof window?window:self;r[e]=n(),"function"==typeof r.Promise&&r[e].auto(r.Promise)}}("extendPromise",function(){var n=e("../index");return n.auto=function(e){n.extendClass(e),n.extendPrototype(e)},n})},{"../index":2}],2:[function(e,n,r){n.exports={extendClass:e("./src/extendClass"),extendPrototype:e("./src/extendPrototype")}},{"./src/extendClass":3,"./src/extendPrototype":4}],3:[function(e,n,r){"use strict";function t(e,n,r){function t(e){if(i(r)){for(var n=!1,t=0;t<r.length;t++)if(r[t]==e){n=!0;break}if(!n)return!1}return!y||!f(d[e])}function o(e,n){return u(n)||(n=+n>0?+n:0),function(r){var t,o=d.defer(),f=0,s=function(i){var c=r[i];d.resolve(c).then(function(r){"undefined"!=typeof n?t.push(r):t[i]=r,(0==--f||!e&&n&&t.length>=n)&&o.resolve(t)},function(e){u(n)?o.reject(e):0==--f&&o.resolve(t)}),f++};if(i(r)){t=[],0==r.length&&o.resolve(t);for(var l=0;l<r.length;l++)s(l)}else if(e&&c(r)){var a=0;t={};for(var l in r)s(l),a++;0==a&&o.resolve(t)}else o.reject(new TypeError("参数错误"));return o.promise}}function l(e){for(var n=d.defer(),r=0;r<e.length;r++)!function(){var t=r,o=e[t];d.resolve(o).then(function(e){n.resolve(e)},function(e){n.reject(e)})}();return n.promise}function a(e){return function(n,r){return n?e.reject(n):void e.resolve(r)}}function p(e){var n=this===d?null:this,r=d.defer(),t=s(arguments,1);return t.push(a(r)),e.apply(n,t),r.promise}var d,y;if(n?(y=!0,d=n):d=e,d.Promise||e==n||(d.Promise=e),f(e)&&f(e.prototype.then))d.defer=function(){var n,r,t=new e(function(e,t){n=e,r=t});return{promise:t,resolve:n,reject:r}};else if(f(e.defer))d.defer=function(){return e.defer()};else{if(!f(e.deferred))throw new TypeError("此类不支持扩展!");d.defer=function(){return e.deferred()}}return t("delay")&&(d.delay=function(e,n){var r=d.defer();return setTimeout(function(){r.resolve(n)},e),r.promise}),t("resolve")&&(d.resolve=function(e){var n=d.defer();return n.resolve(e),n.promise}),t("reject")&&(d.reject=function(e){var n=d.defer();return n.reject(e),n.promise}),t("all")&&(d.all=o()),t("allMap")&&(d.allMap=o(!0)),t("some")&&(d.some=function(e,n){return n=+n>=0?+n:0,o(!1,n)(e)}),t("map")&&(d.map=function(e,n,r){function t(){if(c<s.length){var r=s[c],f=d.resolve(n(e[r],r,e)).then(function(e){return t(),e},o.reject);i.push(f),u--,c++}else d.all(i).then(o.resolve,o.reject)}var o=d.defer(),i=[],u=r?+r.concurrency:0;if(0==u||u!=u){for(var f in e)i.push(n(e[f],f,e));return d.all(i).then(o.resolve,o.reject),o.promise}var c=0,s=function(){var n=[];for(var r in e)n.push(r);return n}();do t();while(u>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,n){var r=this===d?null:this,t=d.defer();if(!i(n))throw TypeError('"args" is not Array');return n.push(a(t)),e.apply(r,n),t.promise}),d.denodeify=function(e){var n=this===d?null:this;return function(){return p.apply(n,[].concat([e],s(arguments)))}},d}var o=e("./utils"),i=o.isArray,u=o.isEmpty,f=o.isFunction,c=o.isPlainObject,s=o.arg2arr;n.exports=t},{"./utils":5}],4:[function(e,n,r){function t(e){var n=e.prototype;return n.done=function(e,n){this.then(function(n){"function"==typeof e&&setTimeout(function(){e(n)},0)},function(e){"function"==typeof n?setTimeout(function(){n(e)},0):setTimeout(function(){throw e},0)})},n.spread=function(e,n){return this.then(function(n){return e.apply(null,n)},n)},n.fail=n.catch=function(e){return this.then(null,e)},n.catchOf=function(e,n){return n=n||e,this.then(null,function(r){var t=typeof n;if("function"!=t)throw r;if(e===n)return n(r);if(e===r||"function"==typeof e&&r instanceof e)return n(r);throw r})},n.error=function(e){return this.catchOf(Error,e)},n.fin=n.finally=function(e){var n=function(n,r){try{e(n,r)}catch(e){}};return this.then(function(e){return n(e),e},function(e){throw n(null,e),e})},e}n.exports=t},{}],5:[function(e,n,r){"use strict";r.isPlainObject=function(e){return null!==e&&"object"==typeof e&&!e.nodeType&&e!==e.window&&!(e.constructor&&!Object.prototype.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))},r.isArray=function(e){return"[object Array]"==Object.prototype.toString.call(e)},r.isFunction=function(e){return"function"==typeof e},r.isEmpty=function(e){return"undefined"==typeof e||null===e},r.arg2arr=function(e,n,r){return Array.prototype.slice.call(e,n,r)}},{}]},{},[1]); | ||
!function e(n,r,t){function o(u,f){if(!r[u]){if(!n[u]){var c="function"==typeof require&&require;if(!f&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var s=r[u]={exports:{}};n[u][0].call(s.exports,function(e){var r=n[u][1][e];return o(r?r:e)},s,s.exports,e,n,r,t)}return r[u].exports}for(var i="function"==typeof require&&require,u=0;u<t.length;u++)o(t[u]);return o}({1:[function(e,n,r){!function(e,n){if("function"==typeof define&&(define.amd||define.cmd))define([],n);else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("加载 "+e+" 模块失败!,请检查您的环境!");var r="undefined"!=typeof window?window:self;r[e]=n(),"function"==typeof r.Promise&&r[e].auto(r.Promise)}}("extendPromise",function(){var n=e("../index");return n.auto=function(e){n.extendClass(e),n.extendPrototype(e)},n})},{"../index":2}],2:[function(e,n,r){n.exports={extendClass:e("./src/extendClass"),extendPrototype:e("./src/extendPrototype")}},{"./src/extendClass":3,"./src/extendPrototype":4}],3:[function(e,n,r){"use strict";function t(e,n,r){function t(e){if(i(r)){for(var n=!1,t=0;t<r.length;t++)if(r[t]==e){n=!0;break}if(!n)return!1}return!h||!f(d[e])}function o(e,n){return u(n)||(n=+n>0?+n:0),function(r){var t,o=d.defer(),f=0,s=function(i){var c=r[i];d.resolve(c).then(function(r){"undefined"!=typeof n?t.push(r):t[i]=r,(0==--f||!e&&n&&t.length>=n)&&o.resolve(t)},function(e){u(n)?o.reject(e):0==--f&&o.resolve(t)}),f++};if(i(r)){t=[],0==r.length&&o.resolve(t);for(var l=0;l<r.length;l++)s(l)}else if(e&&c(r)){var a=0;t={};for(var l in r)s(l),a++;0==a&&o.resolve(t)}else o.reject(new TypeError("参数错误"));return o.promise}}function l(e){for(var n=d.defer(),r=0;r<e.length;r++)!function(){var t=r,o=e[t];d.resolve(o).then(function(e){n.resolve(e)},function(e){n.reject(e)})}();return n.promise}function a(e){return function(n,r){return n?e.reject(n):void e.resolve(r)}}function p(e){var n=this===d?null:this,r=d.defer(),t=s(arguments,1);return t.push(a(r)),e.apply(n,t),r.promise}var d,h;if(n?(h=!0,d=n):d=e,d.Promise||e==n||(d.Promise=e),f(e)&&f(e.prototype.then))d.defer=function(){var n,r,t=new e(function(e,t){n=e,r=t});return{promise:t,resolve:n,reject:r}};else if(f(e.defer))d.defer=function(){return e.defer()};else{if(!f(e.deferred))throw new TypeError("此类不支持扩展!");d.defer=function(){return e.deferred()}}return t("delay")&&(d.delay=function(e,n){var r=d.defer();return setTimeout(function(){r.resolve(n)},e),r.promise}),t("resolve")&&(d.resolve=function(e){var n=d.defer();return n.resolve(e),n.promise}),t("reject")&&(d.reject=function(e){var n=d.defer();return n.reject(e),n.promise}),t("all")&&(d.all=o()),t("allMap")&&(d.allMap=o(!0)),t("some")&&(d.some=function(e,n){return n=+n>=0?+n:0,o(!1,n)(e)}),t("map")&&(d.map=function(e,n,r){function t(){if(c<s.length){var r=s[c],f=d.resolve(n(e[r],r,e)).then(function(e){return t(),e},o.reject);i.push(f),u--,c++}else d.all(i).then(o.resolve,o.reject)}var o=d.defer(),i=[],u=r?+r.concurrency:0;if(0==u||u!=u){for(var f in e)i.push(n(e[f],f,e));return d.all(i).then(o.resolve,o.reject),o.promise}var c=0,s=function(){var n=[];for(var r in e)n.push(r);return n}();do t();while(u>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,n){var r=this===d?null:this,t=d.defer();if(!i(n))throw TypeError('"args" is not Array');return n.push(a(t)),e.apply(r,n),t.promise}),d.denodeify=function(e){var n=this===d?null:this;return function(){return p.apply(n,[].concat([e],s(arguments)))}},d}var o=e("./utils"),i=o.isArray,u=o.isEmpty,f=o.isFunction,c=o.isPlainObject,s=o.arg2arr;n.exports=t},{"./utils":5}],4:[function(e,n,r){function t(e){var n=e.prototype;return n.done=function(e,n){this.then(function(n){"function"==typeof e&&setTimeout(function(){e(n)},0)},function(e){"function"==typeof n?setTimeout(function(){n(e)},0):setTimeout(function(){throw e},0)})},n.spread=function(e,n){return this.then(function(n){return e.apply(null,n)},n)},n.fail=n.catch=function(e){return this.then(null,e)},n.catchOf=function(e,n){return n=n||e,this.then(null,function(r){var t=typeof n;if("function"!=t)throw r;if(e===n)return n(r);if(e===r||"function"==typeof e&&r instanceof e)return n(r);throw r})},n.error=function(e){return this.catchOf(Error,e)},n.fin=n.finally=function(n){return"function"!=typeof n?this:this.then(function(r){return e.resolve(n()).then(function(){return r})},function(r){return e.resolve(n()).then(function(){throw r})})},e}n.exports=t},{}],5:[function(e,n,r){"use strict";r.isPlainObject=function(e){return null!==e&&"object"==typeof e&&!e.nodeType&&e!==e.window&&!(e.constructor&&!Object.prototype.hasOwnProperty.call(e.constructor.prototype,"isPrototypeOf"))},r.isArray=function(e){return"[object Array]"==Object.prototype.toString.call(e)},r.isFunction=function(e){return"function"==typeof e},r.isEmpty=function(e){return"undefined"==typeof e||null===e},r.arg2arr=function(e,n,r){return Array.prototype.slice.call(e,n,r)}},{}]},{},[1]); |
/*! | ||
* extend-promise v0.0.6 | ||
* extend-promise v0.0.7 | ||
* Homepage https://github.com/cnwhy/extend-promise#readme | ||
@@ -341,11 +341,9 @@ * License BSD-2-Clause | ||
prototype.fin = | ||
prototype['finally'] = function(fun){ | ||
var run = function(y,n){try{fun(y,n);}catch(e){}} | ||
return this.then(function(data){ | ||
run(data); | ||
return data; | ||
prototype['finally'] = function(fn){ | ||
if(typeof fn !== "function") return this; | ||
return this.then(function(v){ | ||
return Promise.resolve(fn()).then(function(){return v}) | ||
},function(err){ | ||
run(null,err); | ||
throw err; | ||
}) | ||
return Promise.resolve(fn()).then(function(){throw err;}) | ||
}); | ||
} | ||
@@ -357,5 +355,5 @@ return Promise; | ||
module.exports = function(Promise){ | ||
require("../src/extendClass")(Promise), | ||
require("../src/extendClass")(Promise) | ||
require("../src/extendPrototype")(Promise) | ||
return(Promise) | ||
return Promise; | ||
} | ||
@@ -362,0 +360,0 @@ },{"../src/extendClass":2,"../src/extendPrototype":3}],5:[function(require,module,exports){ |
/*! | ||
* extend-promise v0.0.6 | ||
* extend-promise v0.0.7 | ||
* 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]); | ||
!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!d||!u(h[e])}function o(e,r){return f(r)||(r=+r>0?+r:0),function(n){var t,o=h.defer(),u=0,s=function(i){var c=n[i];h.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=h.defer(),n=0;n<e.length;n++)!function(){var t=n,o=e[t];h.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===h?null:this,n=h.defer(),t=s(arguments,1);return t.push(a(n)),e.apply(r,t),n.promise}var h,d;if(r?(d=!0,h=r):h=e,h.Promise||e==r||(h.Promise=e),u(e)&&u(e.prototype.then))h.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))h.defer=function(){return e.defer()};else{if(!u(e.deferred))throw new TypeError("此类不支持扩展!");h.defer=function(){return e.deferred()}}return t("delay")&&(h.delay=function(e,r){var n=h.defer();return setTimeout(function(){n.resolve(r)},e),n.promise}),t("resolve")&&(h.resolve=function(e){var r=h.defer();return r.resolve(e),r.promise}),t("reject")&&(h.reject=function(e){var r=h.defer();return r.reject(e),r.promise}),t("all")&&(h.all=o()),t("allMap")&&(h.allMap=o(!0)),t("some")&&(h.some=function(e,r){return r=+r>=0?+r:0,o(!1,r)(e)}),t("map")&&(h.map=function(e,r,n){function t(){if(c<s.length){var n=s[c],u=h.resolve(r(e[n],n,e)).then(function(e){return t(),e},o.reject);i.push(u),f--,c++}else h.all(i).then(o.resolve,o.reject)}var o=h.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 h.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")&&(h.race=l),t("any")&&(h.any=l),t("nfcall")&&(h.nfcall=p),t("nfapply")&&(h.nfapply=function(e,r){var n=this===h?null:this,t=h.defer();if(!i(r))throw TypeError('"args" is not Array');return r.push(a(t)),e.apply(n,r),t.promise}),h.denodeify=function(e){var r=this===h?null:this;return function(){return p.apply(r,[].concat([e],s(arguments)))}},h}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(r){return"function"!=typeof r?this:this.then(function(n){return e.resolve(r()).then(function(){return n})},function(n){return e.resolve(r()).then(function(){throw n})})},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]); |
/*! | ||
* extend-promise v0.0.6 | ||
* extend-promise v0.0.7 | ||
* Homepage https://github.com/cnwhy/extend-promise#readme | ||
@@ -23,3 +23,2 @@ * License BSD-2-Clause | ||
},{"./src":3}],3:[function(require,module,exports){ | ||
"use strict"; | ||
module.exports = function(nextTick){ | ||
@@ -62,9 +61,2 @@ var FUN = function(){}; | ||
function bind(fun,self){ | ||
var arg = Array.prototype.slice.call(arguments,2); | ||
return function(){ | ||
fun.apply(self,arg.concat(Array.prototype.slice.call(arguments))); | ||
} | ||
} | ||
function Promise_(fun){ | ||
@@ -131,4 +123,21 @@ //var defer = this.defer = new Defer(this); | ||
} | ||
Promise_.all = function(arr){ | ||
if(Object.prototype.toString.call(arr) !== "[object Array]") throw new TypeError('The argument is not an array!') | ||
return new Promise_(function(ok,no){ | ||
var result = [], _n = 0; | ||
var count = arr.length; | ||
var su = function(i){ | ||
return function(v){ | ||
result[i]=v; | ||
if(++_n == count) ok(result); | ||
} | ||
} | ||
if(count<=0) return ok([]); | ||
for(var i =0; i < count; i++){ | ||
Promise_.resolve(arr[i]).then(su(i),no); | ||
} | ||
}) | ||
} | ||
Promise.prototype.toString = function () { | ||
Promise_.prototype.toString = function () { | ||
return "[object Promise]"; | ||
@@ -153,7 +162,15 @@ } | ||
// this._events.push([ok,no,promise]); | ||
// runThens.call(this) | ||
return promise; | ||
} | ||
Promise_.prototype['catch'] = function(fn){ | ||
return this.then(null,fn); | ||
} | ||
Promise_.prototype['finally'] = function(fn){ | ||
if(typeof fn !== "function") return this; | ||
return this.then(function(v){ | ||
return Promise_.resolve(fn()).then(function(){return v}) | ||
},function(err){ | ||
return Promise_.resolve(fn()).then(function(){throw err;}) | ||
}); | ||
} | ||
function changeStatus(status,arg){ | ||
@@ -193,6 +210,3 @@ var self = this; | ||
,reject = nextQ.reject | ||
// if(nextQ){ | ||
// resolve = nextQ.resolve | ||
// reject = nextQ.reject | ||
// } | ||
if(typeof fn == 'function'){ | ||
@@ -205,4 +219,2 @@ nextTick(function(){ | ||
reject(e) | ||
// if(reject) | ||
// else throw e; | ||
return; | ||
@@ -538,11 +550,9 @@ } | ||
prototype.fin = | ||
prototype['finally'] = function(fun){ | ||
var run = function(y,n){try{fun(y,n);}catch(e){}} | ||
return this.then(function(data){ | ||
run(data); | ||
return data; | ||
prototype['finally'] = function(fn){ | ||
if(typeof fn !== "function") return this; | ||
return this.then(function(v){ | ||
return Promise.resolve(fn()).then(function(){return v}) | ||
},function(err){ | ||
run(null,err); | ||
throw err; | ||
}) | ||
return Promise.resolve(fn()).then(function(){throw err;}) | ||
}); | ||
} | ||
@@ -554,5 +564,5 @@ return Promise; | ||
module.exports = function(Promise){ | ||
require("../src/extendClass")(Promise), | ||
require("../src/extendClass")(Promise) | ||
require("../src/extendPrototype")(Promise) | ||
return(Promise) | ||
return Promise; | ||
} | ||
@@ -559,0 +569,0 @@ },{"../src/extendClass":5,"../src/extendPrototype":6}],8:[function(require,module,exports){ |
/*! | ||
* extend-promise v0.0.6 | ||
* extend-promise v0.0.7 | ||
* Homepage https://github.com/cnwhy/extend-promise#readme | ||
* License BSD-2-Clause | ||
*/ | ||
!function e(t,n,r){function o(u,f){if(!n[u]){if(!t[u]){var c="function"==typeof require&&require;if(!f&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var s=n[u]={exports:{}};t[u][0].call(s.exports,function(e){var n=t[u][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,t,n){!function(e,t){if("function"==typeof define&&(define.amd||define.cmd))define([],t);else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("加载 "+e+" 模块失败!,请检查您的环境!");var n="undefined"!=typeof window?window:self;n[e]=t()}}("Promise",function(){var t=e("../promise/setTimeout");return t})},{"../promise/setTimeout":4}],2:[function(e,t,n){t.exports=e("./src")(function(e){setTimeout(e,0)})},{"./src":3}],3:[function(e,t,n){"use strict";t.exports=function(e){function t(e,r){if(n(r))r.then(e.resolve,e.reject);else if(!r||"function"!=typeof r&&"object"!=typeof r)e.resolve(r);else{var o,i=!1;try{o=r.then,"function"==typeof o?o.call(r,function(n){i||(i=!0,t(e,n))},function(t){i||(i=!0,e.reject(t))}):e.resolve(r)}catch(t){i||(i=!0,e.reject(t))}}}function n(e){return e instanceof r}function r(e){function n(e){o.call(c,1,e)}function r(e){o.call(c,0,e)}function i(e){if(!s)return s=!0,c===e?r(new TypeError("The promise and its value refer to the same object")):void t({resolve:n,reject:r},e)}function u(e){s||(s=!0,r(e))}var c=this;this.status=-1,this._events=[];var s=!1;if(this.resolve=i,this.reject=u,e!==f&&"function"==typeof e)try{e(this.resolve,this.reject)}catch(e){this.reject(e)}}function o(e,t){var n=this;~this.status||(this.status=e,e?this.value=t:this.reason=t,i.call(n))}function i(){if(~this.status){for(var e=this,t=e._events,n=e.status?e.value:e.reason,r=e.status?0:1,o=0;o<t.length;o++)!function(t){var o=t[r],i=t[2];u(o,n,i,e.status)}(t[o]);t=[]}}function u(t,n,r,o){var i=r.resolve,u=r.reject;"function"==typeof t?e(function(){var e;try{e=t(n)}catch(e){return void u(e)}i(e)}):o?i(n):u(n)}var f=function(){};return r.defer=function(){var e=new r(f);return{promise:e,resolve:e.resolve,reject:e.reject}},r.resolve=function(e){return n(e)?e:new r(function(t,n){t(e)})},r.reject=function(e){return new r(function(t,n){n(e)})},Promise.prototype.toString=function(){return"[object Promise]"},r.prototype.then=function(e,t){var n=this.status,o=r.defer(),i=o.promise;return~n?n&&"function"==typeof e?u(e,this.value,i,n):n||"function"!=typeof t?n?o.resolve(this.value):o.reject(this.reason):u(t,this.reason,i,n):this._events.push([e,t,i]),i},r}},{}],4:[function(e,t,n){var r=e("easy-promise/setTimeout");t.exports=e("../src/polyfills")(r)},{"../src/polyfills":7,"easy-promise/setTimeout":2}],5:[function(e,t,n){"use strict";function r(e,t,n){function r(e){if(i(n)){for(var t=!1,r=0;r<n.length;r++)if(n[r]==e){t=!0;break}if(!t)return!1}return!v||!f(h[e])}function o(e,t){return u(t)||(t=+t>0?+t:0),function(n){var r,o=h.defer(),f=0,s=function(i){var c=n[i];h.resolve(c).then(function(n){"undefined"!=typeof t?r.push(n):r[i]=n,(0==--f||!e&&t&&r.length>=t)&&o.resolve(r)},function(e){u(t)?o.reject(e):0==--f&&o.resolve(r)}),f++};if(i(n)){r=[],0==n.length&&o.resolve(r);for(var a=0;a<n.length;a++)s(a)}else if(e&&c(n)){var l=0;r={};for(var a in n)s(a),l++;0==l&&o.resolve(r)}else o.reject(new TypeError("参数错误"));return o.promise}}function a(e){for(var t=h.defer(),n=0;n<e.length;n++)!function(){var r=n,o=e[r];h.resolve(o).then(function(e){t.resolve(e)},function(e){t.reject(e)})}();return t.promise}function l(e){return function(t,n){return t?e.reject(t):void e.resolve(n)}}function p(e){var t=this===h?null:this,n=h.defer(),r=s(arguments,1);return r.push(l(n)),e.apply(t,r),n.promise}var h,v;if(t?(v=!0,h=t):h=e,h.Promise||e==t||(h.Promise=e),f(e)&&f(e.prototype.then))h.defer=function(){var t,n,r=new e(function(e,r){t=e,n=r});return{promise:r,resolve:t,reject:n}};else if(f(e.defer))h.defer=function(){return e.defer()};else{if(!f(e.deferred))throw new TypeError("此类不支持扩展!");h.defer=function(){return e.deferred()}}return r("delay")&&(h.delay=function(e,t){var n=h.defer();return setTimeout(function(){n.resolve(t)},e),n.promise}),r("resolve")&&(h.resolve=function(e){var t=h.defer();return t.resolve(e),t.promise}),r("reject")&&(h.reject=function(e){var t=h.defer();return t.reject(e),t.promise}),r("all")&&(h.all=o()),r("allMap")&&(h.allMap=o(!0)),r("some")&&(h.some=function(e,t){return t=+t>=0?+t:0,o(!1,t)(e)}),r("map")&&(h.map=function(e,t,n){function r(){if(c<s.length){var n=s[c],f=h.resolve(t(e[n],n,e)).then(function(e){return r(),e},o.reject);i.push(f),u--,c++}else h.all(i).then(o.resolve,o.reject)}var o=h.defer(),i=[],u=n?+n.concurrency:0;if(0==u||u!=u){for(var f in e)i.push(t(e[f],f,e));return h.all(i).then(o.resolve,o.reject),o.promise}var c=0,s=function(){var t=[];for(var n in e)t.push(n);return t}();do r();while(u>0&&c<s.length);return o.promise}),r("race")&&(h.race=a),r("any")&&(h.any=a),r("nfcall")&&(h.nfcall=p),r("nfapply")&&(h.nfapply=function(e,t){var n=this===h?null:this,r=h.defer();if(!i(t))throw TypeError('"args" is not Array');return t.push(l(r)),e.apply(n,t),r.promise}),h.denodeify=function(e){var t=this===h?null:this;return function(){return p.apply(t,[].concat([e],s(arguments)))}},h}var o=e("./utils"),i=o.isArray,u=o.isEmpty,f=o.isFunction,c=o.isPlainObject,s=o.arg2arr;t.exports=r},{"./utils":8}],6:[function(e,t,n){function r(e){var t=e.prototype;return t.done=function(e,t){this.then(function(t){"function"==typeof e&&setTimeout(function(){e(t)},0)},function(e){"function"==typeof t?setTimeout(function(){t(e)},0):setTimeout(function(){throw e},0)})},t.spread=function(e,t){return this.then(function(t){return e.apply(null,t)},t)},t.fail=t.catch=function(e){return this.then(null,e)},t.catchOf=function(e,t){return t=t||e,this.then(null,function(n){var r=typeof t;if("function"!=r)throw n;if(e===t)return t(n);if(e===n||"function"==typeof e&&n instanceof e)return t(n);throw n})},t.error=function(e){return this.catchOf(Error,e)},t.fin=t.finally=function(e){var t=function(t,n){try{e(t,n)}catch(e){}};return this.then(function(e){return t(e),e},function(e){throw t(null,e),e})},e}t.exports=r},{}],7:[function(e,t,n){t.exports=function(t){return e("../src/extendClass")(t),e("../src/extendPrototype")(t),t}},{"../src/extendClass":5,"../src/extendPrototype":6}],8:[function(e,t,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,t,n){return Array.prototype.slice.call(e,t,n)}},{}]},{},[1]); | ||
!function e(t,n,r){function o(u,f){if(!n[u]){if(!t[u]){var c="function"==typeof require&&require;if(!f&&c)return c(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var s=n[u]={exports:{}};t[u][0].call(s.exports,function(e){var n=t[u][1][e];return o(n?n:e)},s,s.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,t,n){!function(e,t){if("function"==typeof define&&(define.amd||define.cmd))define([],t);else{if("undefined"==typeof window&&"undefined"==typeof self)throw new Error("加载 "+e+" 模块失败!,请检查您的环境!");var n="undefined"!=typeof window?window:self;n[e]=t()}}("Promise",function(){var t=e("../promise/setTimeout");return t})},{"../promise/setTimeout":4}],2:[function(e,t,n){t.exports=e("./src")(function(e){setTimeout(e,0)})},{"./src":3}],3:[function(e,t,n){t.exports=function(e){function t(e,r){if(n(r))r.then(e.resolve,e.reject);else if(!r||"function"!=typeof r&&"object"!=typeof r)e.resolve(r);else{var o,i=!1;try{o=r.then,"function"==typeof o?o.call(r,function(n){i||(i=!0,t(e,n))},function(t){i||(i=!0,e.reject(t))}):e.resolve(r)}catch(t){i||(i=!0,e.reject(t))}}}function n(e){return e instanceof r}function r(e){function n(e){o.call(c,1,e)}function r(e){o.call(c,0,e)}function i(e){if(!s)return s=!0,c===e?r(new TypeError("The promise and its value refer to the same object")):void t({resolve:n,reject:r},e)}function u(e){s||(s=!0,r(e))}var c=this;this.status=-1,this._events=[];var s=!1;if(this.resolve=i,this.reject=u,e!==f&&"function"==typeof e)try{e(this.resolve,this.reject)}catch(e){this.reject(e)}}function o(e,t){var n=this;~this.status||(this.status=e,e?this.value=t:this.reason=t,i.call(n))}function i(){if(~this.status){for(var e=this,t=e._events,n=e.status?e.value:e.reason,r=e.status?0:1,o=0;o<t.length;o++)!function(t){var o=t[r],i=t[2];u(o,n,i,e.status)}(t[o]);t=[]}}function u(t,n,r,o){var i=r.resolve,u=r.reject;"function"==typeof t?e(function(){var e;try{e=t(n)}catch(e){return void u(e)}i(e)}):o?i(n):u(n)}var f=function(){};return r.defer=function(){var e=new r(f);return{promise:e,resolve:e.resolve,reject:e.reject}},r.resolve=function(e){return n(e)?e:new r(function(t,n){t(e)})},r.reject=function(e){return new r(function(t,n){n(e)})},r.all=function(e){if("[object Array]"!==Object.prototype.toString.call(e))throw new TypeError("The argument is not an array!");return new r(function(t,n){var o=[],i=0,u=e.length,f=function(e){return function(n){o[e]=n,++i==u&&t(o)}};if(u<=0)return t([]);for(var c=0;c<u;c++)r.resolve(e[c]).then(f(c),n)})},r.prototype.toString=function(){return"[object Promise]"},r.prototype.then=function(e,t){var n=this.status,o=r.defer(),i=o.promise;return~n?n&&"function"==typeof e?u(e,this.value,i,n):n||"function"!=typeof t?n?o.resolve(this.value):o.reject(this.reason):u(t,this.reason,i,n):this._events.push([e,t,i]),i},r.prototype.catch=function(e){return this.then(null,e)},r.prototype.finally=function(e){return"function"!=typeof e?this:this.then(function(t){return r.resolve(e()).then(function(){return t})},function(t){return r.resolve(e()).then(function(){throw t})})},r}},{}],4:[function(e,t,n){var r=e("easy-promise/setTimeout");t.exports=e("../src/polyfills")(r)},{"../src/polyfills":7,"easy-promise/setTimeout":2}],5:[function(e,t,n){"use strict";function r(e,t,n){function r(e){if(i(n)){for(var t=!1,r=0;r<n.length;r++)if(n[r]==e){t=!0;break}if(!t)return!1}return!v||!f(h[e])}function o(e,t){return u(t)||(t=+t>0?+t:0),function(n){var r,o=h.defer(),f=0,s=function(i){var c=n[i];h.resolve(c).then(function(n){"undefined"!=typeof t?r.push(n):r[i]=n,(0==--f||!e&&t&&r.length>=t)&&o.resolve(r)},function(e){u(t)?o.reject(e):0==--f&&o.resolve(r)}),f++};if(i(n)){r=[],0==n.length&&o.resolve(r);for(var l=0;l<n.length;l++)s(l)}else if(e&&c(n)){var a=0;r={};for(var l in n)s(l),a++;0==a&&o.resolve(r)}else o.reject(new TypeError("参数错误"));return o.promise}}function l(e){for(var t=h.defer(),n=0;n<e.length;n++)!function(){var r=n,o=e[r];h.resolve(o).then(function(e){t.resolve(e)},function(e){t.reject(e)})}();return t.promise}function a(e){return function(t,n){return t?e.reject(t):void e.resolve(n)}}function p(e){var t=this===h?null:this,n=h.defer(),r=s(arguments,1);return r.push(a(n)),e.apply(t,r),n.promise}var h,v;if(t?(v=!0,h=t):h=e,h.Promise||e==t||(h.Promise=e),f(e)&&f(e.prototype.then))h.defer=function(){var t,n,r=new e(function(e,r){t=e,n=r});return{promise:r,resolve:t,reject:n}};else if(f(e.defer))h.defer=function(){return e.defer()};else{if(!f(e.deferred))throw new TypeError("此类不支持扩展!");h.defer=function(){return e.deferred()}}return r("delay")&&(h.delay=function(e,t){var n=h.defer();return setTimeout(function(){n.resolve(t)},e),n.promise}),r("resolve")&&(h.resolve=function(e){var t=h.defer();return t.resolve(e),t.promise}),r("reject")&&(h.reject=function(e){var t=h.defer();return t.reject(e),t.promise}),r("all")&&(h.all=o()),r("allMap")&&(h.allMap=o(!0)),r("some")&&(h.some=function(e,t){return t=+t>=0?+t:0,o(!1,t)(e)}),r("map")&&(h.map=function(e,t,n){function r(){if(c<s.length){var n=s[c],f=h.resolve(t(e[n],n,e)).then(function(e){return r(),e},o.reject);i.push(f),u--,c++}else h.all(i).then(o.resolve,o.reject)}var o=h.defer(),i=[],u=n?+n.concurrency:0;if(0==u||u!=u){for(var f in e)i.push(t(e[f],f,e));return h.all(i).then(o.resolve,o.reject),o.promise}var c=0,s=function(){var t=[];for(var n in e)t.push(n);return t}();do r();while(u>0&&c<s.length);return o.promise}),r("race")&&(h.race=l),r("any")&&(h.any=l),r("nfcall")&&(h.nfcall=p),r("nfapply")&&(h.nfapply=function(e,t){var n=this===h?null:this,r=h.defer();if(!i(t))throw TypeError('"args" is not Array');return t.push(a(r)),e.apply(n,t),r.promise}),h.denodeify=function(e){var t=this===h?null:this;return function(){return p.apply(t,[].concat([e],s(arguments)))}},h}var o=e("./utils"),i=o.isArray,u=o.isEmpty,f=o.isFunction,c=o.isPlainObject,s=o.arg2arr;t.exports=r},{"./utils":8}],6:[function(e,t,n){function r(e){var t=e.prototype;return t.done=function(e,t){this.then(function(t){"function"==typeof e&&setTimeout(function(){e(t)},0)},function(e){"function"==typeof t?setTimeout(function(){t(e)},0):setTimeout(function(){throw e},0)})},t.spread=function(e,t){return this.then(function(t){return e.apply(null,t)},t)},t.fail=t.catch=function(e){return this.then(null,e)},t.catchOf=function(e,t){return t=t||e,this.then(null,function(n){var r=typeof t;if("function"!=r)throw n;if(e===t)return t(n);if(e===n||"function"==typeof e&&n instanceof e)return t(n);throw n})},t.error=function(e){return this.catchOf(Error,e)},t.fin=t.finally=function(t){return"function"!=typeof t?this:this.then(function(n){return e.resolve(t()).then(function(){return n})},function(n){return e.resolve(t()).then(function(){throw n})})},e}t.exports=r},{}],7:[function(e,t,n){t.exports=function(t){return e("../src/extendClass")(t),e("../src/extendPrototype")(t),t}},{"../src/extendClass":5,"../src/extendPrototype":6}],8:[function(e,t,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,t,n){return Array.prototype.slice.call(e,t,n)}},{}]},{},[1]); |
{ | ||
"name": "extend-promise", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "基于promise扩展一些常用方法", | ||
@@ -26,3 +26,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"easy-promise": "0.0.3", | ||
"easy-promise": "^0.1.0", | ||
"gulp": "^3.9.1", | ||
@@ -37,4 +37,3 @@ "gulp-browserify": "^0.5.1", | ||
"mocha": "^3.2.0" | ||
}, | ||
"dependencies": {} | ||
} | ||
} |
@@ -50,11 +50,9 @@ function extendPrototype(Promise){ | ||
prototype.fin = | ||
prototype['finally'] = function(fun){ | ||
var run = function(y,n){try{fun(y,n);}catch(e){}} | ||
return this.then(function(data){ | ||
run(data); | ||
return data; | ||
prototype['finally'] = function(fn){ | ||
if(typeof fn !== "function") return this; | ||
return this.then(function(v){ | ||
return Promise.resolve(fn()).then(function(){return v}) | ||
},function(err){ | ||
run(null,err); | ||
throw err; | ||
}) | ||
return Promise.resolve(fn()).then(function(){throw err;}) | ||
}); | ||
} | ||
@@ -61,0 +59,0 @@ return Promise; |
module.exports = function(Promise){ | ||
require("../src/extendClass")(Promise), | ||
require("../src/extendClass")(Promise) | ||
require("../src/extendPrototype")(Promise) | ||
return(Promise) | ||
return Promise; | ||
} |
var assert = require("assert"); | ||
var promise = Promise;//require('easy-promise'); | ||
var promise = typeof Promise != 'undefined' ? Promise : require('easy-promise'); | ||
var utils = require('../src/utils'); | ||
@@ -4,0 +4,0 @@ var EP = require("../"); |
var assert = require("assert"); | ||
var promise = Promise;//require('easy-promise'); | ||
var promise = typeof Promise != 'undefined' ? Promise : require('easy-promise'); | ||
var utils = require('../src/utils'); | ||
@@ -4,0 +4,0 @@ var EP = require("../"); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77459
25
2150