-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.min.js
1 lines (1 loc) · 2.5 KB
/
index.min.js
1
var px=function(a){"use strict";class b{constructor(a){this._supplier=a}static resolve(a){return new b(b=>b(a))}static reject(a){return new b((b,c)=>c(a))}static fromCallable(a){let c;try{c=a()}catch(a){return b.reject(a)}return b.resolve(c)}then(a,b){return new Promise(this._supplier).then(a,b)}catch(a){return new Promise(this._supplier).catch(a)}finally(a){return new Promise(this._supplier).finally(a)}retry(a){let b=this._supplier;if("function"==typeof a){let c=0,d=()=>new Promise(b).then(a=>a,b=>a(++c,b)?d():Promise.reject(b));return d()}let c=()=>new Promise(b).then(a=>a,()=>c());return c()}delay(a){return new b((b,c)=>{setTimeout(()=>{this._supplier(b,c)},a)})}toPromise(){return new Promise(this._supplier)}}class c{constructor(a){this._promise=new Promise((b,c)=>{this._resolve=b,this._reject=c,"function"==typeof a&&a(b,c)})}resolve(a){this._resolve(a)}reject(a){this._reject(a)}then(a,b){return this._promise.then(a,b)}catch(a){return this._promise.catch(a)}finally(a){return this._promise.finally(a)}toPromise(){return this._promise}}return Promise.prototype.contains=function(a,b){return"function"==typeof b?this.then(c=>b(c,a)):this.then(b=>b===a)},Promise.prototype.delay=function(a){return this.then(b=>new Promise(c=>{setTimeout(c,a,b)}),b=>new Promise((c,d)=>{setTimeout(d,a,b)}))},Promise.compare=function(c,a,b){return Promise.all([c,a]).then(a=>b(a[0],a[1]))},Promise.equals=function(c,a){return Promise.compare(c,a,(a,b)=>a===b)},Promise.deferred=function(a){return new b(a)},Promise.prototype.defer=function(){return this.then(a=>b.resolve(a),a=>b.reject(a))},Promise.publish=function(a){return new c(a)},Promise.timer=function(a){return new Promise(b=>{setTimeout(b,a,0)})},Promise.prototype.timeout=function(a){let b=!1;return this.then(()=>{b=!0}),new Promise((c,d)=>{setTimeout(()=>{b?c(this):d(new Error("Promise TimeoutException"))},a)})},Promise.prototype.finally=function(a){return this.then(b=>Promise.resolve(a()).then(()=>b),b=>Promise.resolve(a()).then(()=>{throw b}))},Promise.fromCallable=function(a){let b;try{b=a()}catch(a){return Promise.reject(a)}return Promise.resolve(b)},Promise.fromCallableDeferred=function(a){return b.fromCallable(a)},Promise.delayedResolve=function(a,b){return new Promise(c=>{setTimeout(c,b,a)})},Promise.delayedReject=function(a,b){return new Promise((c,d)=>{setTimeout(d,b,a)})},Promise.prototype.test=function(a){return"function"==typeof a?this.then(b=>new Promise((c,d)=>a(b,!0)?c(b):d(b)),b=>new Promise((c,d)=>a(b,!1)?c(b):d(b))):this},a.DeferredPromise=b,a.PublishedPromise=c,a}({});