!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.creed={})}(this,function(t){"use strict";var e=1,n=2,r=4,o=n|r,i=8,c=16;function u(t){return(t.state()&n)>0}function s(t){return(t.state()&r)>0}function p(t){return(t.state()&o)>0}function a(t){return(t.state()&i)>0}function f(t){return(t.state()&c)>0}function h(t){t._runAction(l)}var l={fulfilled:function(){},rejected:function(t){t._state|=c}},y="undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process),d="function"==typeof MutationObserver&&MutationObserver||"function"==typeof WebKitMutationObserver&&WebKitMutationObserver,v=function(t){return y&&process.env[t]},_=v("CREED_DEBUG")||"development"===v("NODE_ENV")||"test"===v("NODE_ENV");function m(t){return y?(n=t,function(){return process.nextTick(n)}):d?function(t){var e=document.createTextNode("");new d(t).observe(e,{characterData:!0});var n=0;return function(){e.data=n^=1}}(t):(e=t,function(){return setTimeout(e,0)});var e,n}var w=function(){var t=this;this.tasks=new Array(65536),this.length=0,this.drain=m(function(){return t._drain()})};w.prototype.add=function(t){0===this.length&&this.drain(),this.tasks[this.length++]=t},w.prototype._drain=function(){for(var t=this.tasks,e=0;e0},t.isNever=a,t.isHandled=f,t.getValue=function(t){var e=t.near();if(!u(e))throw new TypeError("getValue called on "+t);return e.value},t.getReason=function(t){var e=t.near();if(!s(e))throw new TypeError("getReason called on "+t);return h(e),e.value},t.coroutine=function(t){return function(){for(var e,n,r,o,i,c=[],u=arguments.length;u--;)c[u]=arguments[u];return e=this,n=c,r=vt,o=t.apply(e,n),i=new ht,new Vt(r,o,i).run(),i}},t.fromNode=function(t){return function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];return zt(Ht,t,this,e,new ht)}},t.runNode=function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];return zt(Ht,t,this,e,new ht)},t.runPromise=function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];return zt(Mt,t,this,e,new ht)},t.delay=function(t,e){var n,r,o,i=vt(e);return t<=0||s(i)||a(i)?i:(n=t,r=i,o=new ht,r._runAction(new Tt(n,o)),o)},t.timeout=function(t,e){var n,r,o,i,c=vt(e);return p(c)?c:(n=t,r=c,o=new ht,i=setTimeout(Nt,n,o),r._runAction(new Pt(i,o)),o)},t.any=function(t){return At(new Ft,t)},t.settle=function(t){return At(new Dt(vt,nt(t)),t)},t.merge=function(t){for(var e,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return e=n,At(new et(new Ct(t,this),nt(e)),e)},t.shim=Wt,t.Promise=Kt,Object.defineProperty(t,"__esModule",{value:!0})});