-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d7c9c1
commit 96abd62
Showing
9 changed files
with
147 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* promise-for-es | ||
* @version 1.0.0 | ||
* @author Ambit tsai <ambit_tsai@qq.com> | ||
* @license Apache-2.0 | ||
* @see {@link https://github.com/ambit-tsai/promise-for-es#readme} | ||
*/ | ||
var e,t,n,r="object"==typeof window?window:"object"==typeof global?global:self,o=undefined;try{e=Function("iterable","callback","var i = 0;for (var element of iterable) { callback(element, i++, iterable);}")}catch(R){e=function(e,t){for(var n=0,r=e.length;n<r;++n)t(e[n],n++,e)}}function c(e){return"function"==typeof e}function i(e){return!!e&&("object"==typeof e||c(e))}function a(e){throw new TypeError(e)}function l(e){a("Promise."+e+" called on non-object")}c(r.AggregateError)?t=r.AggregateError:(t=function(e,t){this.errors=e,this.message=t}).prototype=Error.prototype;try{Object.defineProperty({},"",{}),n=function(e,t,n,r){void 0===r&&(r=!1),Object.defineProperty(e,t,{configurable:!r,value:n})}}catch(R){n=function(e,t,n){return e[t]=n}}var u,s=r.MutationObserver||r.WebKitMutationObserver;function f(e,t){var n=e.Capability,r=e.Handler;try{var o=void 0;if(r)o=r(t);else{if("Reject"===e.Type)throw t;o=t}n.Resolve(o)}catch(R){n.Reject(R)}}function v(e){var t=!1;return{resolve:function(r){if(!t){t=!0;try{if(r===e&&a("Chaining cycle detected for promise"),i(r)){var l=r.then;if(c(l))return void u(y,[e,r,l])}!function(e,t){n(e,"_state","fulfilled",!0),n(e,"_result",t,!0);var r=e._fulfillReactions;n(e,"_fulfillReactions",o,!0),n(e,"_rejectReactions",o,!0),p(r,t)}(e,r)}catch(R){h(e,R)}}},reject:function(n){t||(t=!0,h(e,n))}}}function h(e,t){n(e,"_state","rejected",!0),n(e,"_result",t,!0);var r=e._rejectReactions;n(e,"_fulfillReactions",o,!0),n(e,"_rejectReactions",o,!0),e._isHandled,p(r,t)}function p(e,t){for(var n=0,r=e;n<r.length;n++){var o=r[n];u(f,[o,t])}}function y(e,t,n){var r=v(e),o=r.resolve,c=r.reject;try{n.call(t,o,c)}catch(R){c(R)}}function d(e){c(e)&&i(e.prototype)||a("call on non-constructor");var t={};return t.Promise=new e((function(e,n){t.Resolve=e,t.Reject=n})),c(t.Resolve)&&c(t.Reject)||a("Promise resolve or reject function is not callable"),t}u=s?function(e,t){var n=new s((function(){e.apply(o,t),n.disconnect()})),r=document.createElement("a");n.observe(r,{attributes:!0}),r.setAttribute("b","")}:function(e,t){setTimeout((function(){return e.apply(o,t)}))};var j=function(){function r(e){var t=this;t instanceof r||a("call Promise constructor without 'new'"),c(e)||a("argument is not a function"),n(t,"_state","pending"),n(t,"_fulfillReactions",[]),n(t,"_rejectReactions",[]),n(t,"_result",o),n(t,"_isHandled",!1);var i=v(t),l=i.resolve,u=i.reject;try{e(l,u)}catch(R){u(R)}}return r.prototype.then=function(e,t){var i=this;i instanceof r||a("Promise.prototype.then called on incompatible object");var l=d(r),s={Capability:l,Type:"Fulfill",Handler:c(e)?e:o},v={Capability:l,Type:"Reject",Handler:c(t)?t:o};return"pending"===i._state?(i._fulfillReactions.push(s),i._rejectReactions.push(v)):"fulfilled"===i._state?u(f,[s,i._result]):(i._isHandled,u(f,[v,i._result])),n(i,"_isHandled",!0),l.Promise},r.prototype["catch"]=function(e){return this.then(o,e)},r.prototype["finally"]=function(e){var t,n,r=this;return c(e)?(t=function(t){var n=e();return r.constructor.resolve(n).then((function(){return t}))},n=function(t){var n=e();return r.constructor.resolve(n).then((function(){throw t}))}):(t=e,n=e),r.then(t,n)},r.prototype.toString=function(){return"[object Promise]"},r.prototype.toLocaleString=function(){return"[object Promise]"},r.resolve=function(e){var t=this;if(i(t)||l("resolve"),i(e)&&e instanceof t)return e;var n=d(t);return n.Resolve(e),n.Promise},r.reject=function(e){i(this)||l("reject");var t=d(this);return t.Reject(e),t.Promise},r.all=function(t){var n=this;i(n)||l("all");var r=d(n);try{var o=0,c=[];e(t,(function(e,t){o++,n.resolve(e).then((function(e){c[t]=e,--o||r.Resolve(c)}),r.Reject)})),o?c.length=o:r.Resolve(c)}catch(R){r.Reject(R)}return r.Promise},r.race=function(t){var n=this;i(n)||l("race");var r=d(n);try{e(t,(function(e){n.resolve(e).then(r.Resolve,r.Reject)}))}catch(R){r.Reject(R)}return r.Promise},r.allSettled=function(t){var n=this;i(n)||l("allSettled");var r=d(n);try{var o=0,c=[];e(t,(function(e,t){o++,n.resolve(e).then((function(e){c[t]={status:"fulfilled",value:e},--o||r.Resolve(c)}),(function(e){c[t]={status:"rejected",reason:e},--o||r.Resolve(c)}))})),o?c.length=o:r.Resolve(c)}catch(R){r.Reject(R)}return r.Promise},r.any=function(n){var r=this;i(r)||l("any");var o=d(r);try{var c=0,a=[],u="All Promises rejected";e(n,(function(e,n){c++,r.resolve(e).then(o.Resolve,(function(e){a[n]=e,--c||o.Reject(new t(a,u))}))})),c?a.length=c:o.Reject(new t(a,u))}catch(R){o.Reject(R)}return o.Promise},r}();export default j; | ||
//# sourceMappingURL=promise-for-es.mjs.map |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.