Socket
Socket
Sign inDemoInstall

fluture

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fluture - npm Package Compare versions

Comparing version 6.1.0 to 6.1.1

src/future.js

11

index.es.js

@@ -1,10 +0,3 @@

export {
Future,
Future as default,
isFuture,
reject,
of,
never,
isNever
} from './src/core';
export {default, default as Future} from './src/future';
export {isFuture, reject, of, never, isNever} from './src/core';

@@ -11,0 +4,0 @@ export * from './src/dispatchers';

@@ -1,2 +0,1 @@

!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?module.exports=factory(require("denque"),require("sanctuary-type-classes"),require("inspect-f"),require("sanctuary-type-identifiers"),require("concurrify")):"function"==typeof define&&define.amd?define(["denque","sanctuary-type-classes","inspect-f","sanctuary-type-identifiers","concurrify"],factory):global.Fluture=factory(global.Denque,global.sanctuaryTypeClasses,global.inspectf,global.sanctuaryTypeIdentifiers,global.concurrify)}(this,function(Denque,Z,inspectf,type,concurrify){"use strict";function Future(computation){return isFunction(computation)||invalidArgument("Future",0,"be a Function",computation),new Computation(computation)}function isFuture(x){return x instanceof Future||type(x)===$$type}function check$fork(f,c){void 0===f||isFunction(f)&&0===f.length||typeError("Future expected its computation to return a nullary function or void\n Actual: "+show(f)+"\n From calling: "+showf(c))}function Computation(computation){this._computation=computation}function Rejected(value){this._value=value}function Resolved(value){this._value=value}function Never(){}function Eager(future){var this$1=this;this.rej=noop,this.res=noop,this.rejected=!1,this.resolved=!1,this.value=null,this.cancel=future._fork(function(x){this$1.value=x,this$1.rejected=!0,this$1.cancel=noop,this$1.rej(x)},function(x){this$1.value=x,this$1.resolved=!0,this$1.cancel=noop,this$1.res(x)})}function Sequence(spawn,actions){void 0===actions&&(actions=[]),this._spawn=spawn,this._actions=actions}function ap$mval(mval,mfunc){return Z.Apply.test(mfunc)||invalidArgument("Future.ap",1,"be an Apply",mfunc),Z.ap(mval,mfunc)}function ap(mval,mfunc){return Z.Apply.test(mval)||invalidArgument("Future.ap",0,"be an Apply",mval),1===arguments.length?partial1(ap$mval,mval):ap$mval(mval,mfunc)}function map$mapper(mapper,m){return Z.Functor.test(m)||invalidArgument("Future.map",1,"be a Functor",m),Z.map(mapper,m)}function map(mapper,m){return isFunction(mapper)||invalidArgument("Future.map",0,"be a Function",mapper),1===arguments.length?partial1(map$mapper,mapper):map$mapper(mapper,m)}function bimap$lmapper$rmapper(lmapper,rmapper,m){return Z.Bifunctor.test(m)||invalidArgument("Future.bimap",2,"be a Bifunctor",m),Z.bimap(lmapper,rmapper,m)}function bimap$lmapper(lmapper,rmapper,m){return isFunction(rmapper)||invalidArgument("Future.bimap",1,"be a Function",rmapper),2===arguments.length?partial2(bimap$lmapper$rmapper,lmapper,rmapper):bimap$lmapper$rmapper(lmapper,rmapper,m)}function bimap(lmapper,rmapper,m){return isFunction(lmapper)||invalidArgument("Future.bimap",0,"be a Function",lmapper),1===arguments.length?partial1(bimap$lmapper,lmapper):2===arguments.length?bimap$lmapper(lmapper,rmapper):bimap$lmapper(lmapper,rmapper,m)}function chain$chainer(chainer,m){return Z.Chain.test(m)||invalidArgument("Future.chain",1,"be a Chain",m),Z.chain(chainer,m)}function chain(chainer,m){return isFunction(chainer)||invalidArgument("Future.chain",0,"be a Function",chainer),1===arguments.length?partial1(chain$chainer,chainer):chain$chainer(chainer,m)}function mapRej$mapper(mapper,m){return isFuture(m)||invalidFuture("Future.mapRej",1,m),m.mapRej(mapper)}function mapRej(mapper,m){return isFunction(mapper)||invalidArgument("Future.mapRej",0,"be a Function",mapper),1===arguments.length?partial1(mapRej$mapper,mapper):mapRej$mapper(mapper,m)}function chainRej$chainer(chainer,m){return isFuture(m)||invalidFuture("Future.chainRej",1,m),m.chainRej(chainer)}function chainRej(chainer,m){return isFunction(chainer)||invalidArgument("Future.chainRej",0,"be a Function",chainer),1===arguments.length?partial1(chainRej$chainer,chainer):chainRej$chainer(chainer,m)}function lastly$right(right,left){return isFuture(left)||invalidFuture("Future.finally",1,left),left.finally(right)}function lastly(right,left){return isFuture(right)||invalidFuture("Future.finally",0,right),1===arguments.length?partial1(lastly$right,right):lastly$right(right,left)}function and$left(left,right){return isFuture(right)||invalidFuture("Future.and",1,right),left.and(right)}function and(left,right){return isFuture(left)||invalidFuture("Future.and",0,left),1===arguments.length?partial1(and$left,left):and$left(left,right)}function both$left(left,right){return isFuture(right)||invalidFuture("Future.both",1,right),left.both(right)}function both(left,right){return isFuture(left)||invalidFuture("Future.both",0,left),1===arguments.length?partial1(both$left,left):both$left(left,right)}function or$left(left,right){return isFuture(right)||invalidFuture("Future.or",1,right),left.or(right)}function or(left,right){return isFuture(left)||invalidFuture("Future.or",0,left),1===arguments.length?partial1(or$left,left):or$left(left,right)}function race$right(right,left){return isFuture(left)||invalidFuture("Future.race",1,left),left.race(right)}function race(right,left){return isFuture(right)||invalidFuture("Future.race",0,right),1===arguments.length?partial1(race$right,right):race$right(right,left)}function swap(m){return isFuture(m)||invalidFuture("Future.swap",0,m),m.swap()}function fold$f$g(f,g,m){return isFuture(m)||invalidFuture("Future.fold",2,m),m.fold(f,g)}function fold$f(f,g,m){return isFunction(g)||invalidArgument("Future.fold",1,"be a function",g),2===arguments.length?partial2(fold$f$g,f,g):fold$f$g(f,g,m)}function fold(f,g,m){return isFunction(f)||invalidArgument("Future.fold",0,"be a function",f),1===arguments.length?partial1(fold$f,f):2===arguments.length?fold$f(f,g):fold$f(f,g,m)}function fork$f$g(f,g,m){return isFuture(m)||invalidFuture("Future.fork",2,m),m._fork(f,g)}function fork$f(f,g,m){return isFunction(g)||invalidArgument("Future.fork",1,"be a function",g),2===arguments.length?partial2(fork$f$g,f,g):fork$f$g(f,g,m)}function fork(f,g,m){return isFunction(f)||invalidArgument("Future.fork",0,"be a function",f),1===arguments.length?partial1(fork$f,f):2===arguments.length?fork$f(f,g):fork$f(f,g,m)}function promise(m){return isFuture(m)||invalidFuture("Future.promise",0,m),m.promise()}function value$cont(cont,m){return isFuture(m)||invalidFuture("Future.value",1,m),m.value(cont)}function value(cont,m){return isFunction(cont)||invalidArgument("Future.value",0,"be a Function",cont),1===arguments.length?partial1(value$cont,cont):value$cont(cont,m)}function extractLeft(m){return isFuture(m)||invalidFuture("Future.extractLeft",0,m),m.extractLeft()}function extractRight(m){return isFuture(m)||invalidFuture("Future.extractRight",0,m),m.extractRight()}function After$race(other){return other.isSettled()?other:isNever(other)?this:other instanceof After||other instanceof RejectAfter?other._time<this._time?other:this:Core._race.call(this,other)}function After(time,value){this._time=time,this._value=value}function RejectAfter(time,value){this._time=time,this._value=value}function after$time(time,value){return time===1/0?never:new After(time,value)}function after(time,value){return isUnsigned(time)||invalidArgument("Future.after",0,"be a positive integer",time),1===arguments.length?partial1(after$time,time):after$time(time,value)}function rejectAfter$time(time,reason){return time===1/0?never:new RejectAfter(time,reason)}function rejectAfter(time,reason){return isUnsigned(time)||invalidArgument("Future.rejectAfter",0,"be a positive integer",time),1===arguments.length?partial1(rejectAfter$time,time):rejectAfter$time(time,reason)}function Attempt(fn){this._fn=fn}function attempt(f){return isFunction(f)||invalidArgument("Future.try",0,"be a function",f),new Attempt(f)}function Queued(rej,res){this[Rejected$1]=rej,this[Resolved$1]=res}function Cached(pure){this._pure=pure,this.reset()}function cache(m){return isFuture(m)||invalidFuture("Future.cache",0,m),new Cached(m)}function ChainRec(step,init){this._step=step,this._init=init}function chainRec(step,init){return new ChainRec(step,init)}function Encase(fn,a){this._fn=fn,this._a=a}function encase(f,x){return isFunction(f)||invalidArgument("Future.encase",0,"be a function",f),1===arguments.length?partial1(encase,f):new Encase(f,x)}function Encase2(fn,a,b){this._fn=fn,this._a=a,this._b=b}function encase2(f,x,y){switch(isFunction(f)||invalidArgument("Future.encase2",0,"be a function",f),arguments.length){case 1:return partial1(encase2,f);case 2:return partial2(encase2,f,x);default:return new Encase2(f,x,y)}}function Encase3(fn,a,b,c){this._fn=fn,this._a=a,this._b=b,this._c=c}function encase3(f,x,y,z){switch(isFunction(f)||invalidArgument("Future.encase3",0,"be a function",f),arguments.length){case 1:return partial1(encase3,f);case 2:return partial2(encase3,f,x);case 3:return partial3(encase3,f,x,y);default:return new Encase3(f,x,y,z)}}function EncaseN(fn,a){this._fn=fn,this._a=a}function encaseN(f,x){return isFunction(f)||invalidArgument("Future.encaseN",0,"be a function",f),1===arguments.length?partial1(encaseN,f):new EncaseN(f,x)}function EncaseN2(fn,a,b){this._fn=fn,this._a=a,this._b=b}function encaseN2(f,x,y){switch(isFunction(f)||invalidArgument("Future.encaseN2",0,"be a function",f),arguments.length){case 1:return partial1(encaseN2,f);case 2:return partial2(encaseN2,f,x);default:return new EncaseN2(f,x,y)}}function EncaseN$1(fn,a,b,c){this._fn=fn,this._a=a,this._b=b,this._c=c}function encaseN3(f,x,y,z){switch(isFunction(f)||invalidArgument("Future.encaseN3",0,"be a function",f),arguments.length){case 1:return partial1(encaseN3,f);case 2:return partial2(encaseN3,f,x);case 3:return partial3(encaseN3,f,x,y);default:return new EncaseN$1(f,x,y,z)}}function check$promise(p,f,a){return isThenable(p)?p:typeError("Future.encaseP expects the function its given to return a Promise/Thenable\n Actual: "+show(p)+"\n From calling: "+showf(f)+"\n With: "+show(a))}function EncaseP(fn,a){this._fn=fn,this._a=a}function encaseP(f,x){return isFunction(f)||invalidArgument("Future.encaseP",0,"be a function",f),1===arguments.length?partial1(encaseP,f):new EncaseP(f,x)}function check$promise$1(p,f,a,b){return isThenable(p)?p:typeError("Future.encaseP2 expects the function its given to return a Promise/Thenable\n Actual: "+show(p)+"\n From calling: "+showf(f)+"\n With 1: "+show(a)+"\n With 2: "+show(b))}function EncaseP2(fn,a,b){this._fn=fn,this._a=a,this._b=b}function encaseP2(f,x,y){switch(isFunction(f)||invalidArgument("Future.encaseP2",0,"be a function",f),arguments.length){case 1:return partial1(encaseP2,f);case 2:return partial2(encaseP2,f,x);default:return new EncaseP2(f,x,y)}}function check$promise$2(p,f,a,b,c){return isThenable(p)?p:typeError("Future.encaseP3 expects the function its given to return a Promise/Thenable\n Actual: "+show(p)+"\n From calling: "+showf(f)+"\n With 1: "+show(a)+"\n With 2: "+show(b)+"\n With 3: "+show(c))}function EncaseP3(fn,a,b,c){this._fn=fn,this._a=a,this._b=b,this._c=c}function encaseP3(f,x,y,z){switch(isFunction(f)||invalidArgument("Future.encaseP3",0,"be a function",f),arguments.length){case 1:return partial1(encaseP3,f);case 2:return partial2(encaseP3,f,x);case 3:return partial3(encaseP3,f,x,y);default:return new EncaseP3(f,x,y,z)}}function Go(generator){this._generator=generator}function go(generator){return isFunction(generator)||invalidArgument("Future.do",0,"be a Function",generator),new Go(generator)}function check$dispose(m,f,x){isFuture(m)||invalidFuture("Future.hook","the first function its given to return a Future",m,"\n From calling: "+showf(f)+"\n With: "+show(x))}function check$consume(m,f,x){isFuture(m)||invalidFuture("Future.hook","the second function its given to return a Future",m,"\n From calling: "+showf(f)+"\n With: "+show(x))}function Hook(acquire,dispose,consume){this._acquire=acquire,this._dispose=dispose,this._consume=consume}function hook$acquire$cleanup(acquire,cleanup,consume){return isFunction(consume)||invalidArgument("Future.hook",2,"be a Future",consume),new Hook(acquire,cleanup,consume)}function hook$acquire(acquire,cleanup,consume){return isFunction(cleanup)||invalidArgument("Future.hook",1,"be a function",cleanup),2===arguments.length?partial2(hook$acquire$cleanup,acquire,cleanup):hook$acquire$cleanup(acquire,cleanup,consume)}function hook(acquire,cleanup,consume){return isFuture(acquire)||invalidFuture("Future.hook",0,acquire),1===arguments.length?partial1(hook$acquire,acquire):2===arguments.length?hook$acquire(acquire,cleanup):hook$acquire(acquire,cleanup,consume)}function Node(fn){this._fn=fn}function node(f){return isFunction(f)||invalidArgument("Future.node",0,"be a function",f),new Node(f)}function check$ap$f(f){isFunction(f)||typeError("Future#ap expects its first argument to be a Future of a Function\n Actual: Future.of("+show(f)+")")}function ParallelAp(mval,mfunc){this._mval=mval,this._mfunc=mfunc}function isParallel(x){return x instanceof Par||type(x)===Par["@@type"]}function seq(par){return isParallel(par)||invalidArgument("Future.seq",0,"to be a Par",par),par.sequential}function Parallel(max,futures){this._futures=futures,this._length=futures.length,this._max=Math.min(this._length,max)}function parallel$max(max,xs){isArray(xs)||invalidArgument("Future.parallel",1,"be an array",xs);var futures=mapArray(xs,check$parallel);return 0===futures.length?emptyArray:new Parallel(max,futures)}function parallel(max,xs){return isUnsigned(max)||invalidArgument("Future.parallel",0,"be a positive integer",max),1===arguments.length?partial1(parallel$max,max):parallel$max(max,xs)}function check$promise$3(p,f){return isThenable(p)?p:typeError("Future.tryP expects the function its given to return a Promise/Thenable\n Actual: "+show(p)+"\n From calling: "+showf(f))}function TryP(fn){this._fn=fn}function tryP(f){return isFunction(f)||invalidArgument("Future.tryP",0,"be a function",f),new TryP(f)}Denque="default"in Denque?Denque.default:Denque,Z="default"in Z?Z.default:Z,inspectf="default"in inspectf?inspectf.default:inspectf,type="default"in type?type.default:type,concurrify="default"in concurrify?concurrify.default:concurrify;var noop=function(){},moop=function(){return this},show=Z.toString,padf=function(sf,s){return s.replace(/^/gm,sf).replace(sf,"")},showf=function(f){return padf(" ",inspectf(2,f))},mapArray=function(xs,f){for(var l=xs.length,ys=new Array(l),i=0;i<l;i++)ys[i]=f(xs[i],i,xs);return ys},partial1=function(f,a){return function(b,c,d){switch(arguments.length){case 1:return f(a,b);case 2:return f(a,b,c);default:return f(a,b,c,d)}}},partial2=function(f,a,b){return function(c,d){return 1===arguments.length?f(a,b,c):f(a,b,c,d)}},partial3=function(f,a,b,c){return function(d){return f(a,b,c,d)}},escapeTick=function(f){return function(x){setTimeout(function(){f(x)},0)}},isFunction=function(f){return"function"==typeof f},isThenable=function(m){return m instanceof Promise||Boolean(m)&&isFunction(m.then)},isBoolean=function(f){return"boolean"==typeof f},isNumber=function(f){return"number"==typeof f},isUnsigned=function(n){return n===1/0||isNumber(n)&&n>0&&n%1==0},isObject=function(o){return null!==o&&"object"==typeof o},isIterator=function(i){return isObject(i)&&isFunction(i.next)},isArray=Array.isArray,FL={map:"fantasy-land/map",bimap:"fantasy-land/bimap",chain:"fantasy-land/chain",chainRec:"fantasy-land/chainRec",ap:"fantasy-land/ap",of:"fantasy-land/of"},ordinal=["first","second","third","fourth","fifth"],$$type="fluture/Future@2",error=function(message){throw new Error(message)},typeError=function(message){throw new TypeError(message)},invalidArgument=function(it,at,expected,actual){return typeError(it+" expects its "+ordinal[at]+" argument to "+expected+"\n Actual: "+show(actual))},invalidContext=function(it,actual){return typeError(it+" was invoked outside the context of a Future. You might want to use a dispatcher instead\n Called on: "+show(actual))},invalidNamespace=function(m,x){return"The Future was not created by fluture. Make sure you transform other Futures to fluture Futures. Got "+(x?"a Future from "+x:"an unscoped Future")+".\n See: https://github.com/fluture-js/Fluture#casting-futures"},invalidVersion=function(m,x){return"The Future was created by "+(x<2?"an older":"a newer")+" version of fluture. This means that one of the sources which creates Futures is outdated. Update this source, or transform its created Futures to be compatible.\n See: https://github.com/fluture-js/Fluture#casting-futures"},invalidFuture=function(it,at,m,s){void 0===s&&(s="");var id=type.parse(type(m)),info="Future"===id.name?"\n"+("fluture"!==id.namespace?invalidNamespace(0,id.namespace):2!==id.version?invalidVersion(0,id.version):"Nothing seems wrong. Contact the Fluture maintainers."):"";typeError(it+" expects "+(ordinal[at]?"its "+ordinal[at]+" argument to be a valid Future":at)+"."+info+"\n Actual: "+show(m)+" :: "+id.name+s)},throwRejection=function(x){return error("Future#value was called on a rejected Future\n Actual: Future.reject("+show(x)+")")};Future.prototype[FL.ap]=function(other){return other._ap(this)},Future.prototype[FL.map]=function(mapper){return this._map(mapper)},Future.prototype[FL.bimap]=function(lmapper,rmapper){return this._bimap(lmapper,rmapper)},Future.prototype[FL.chain]=function(mapper){return this._chain(mapper)},Future.prototype.ap=function(other){return isFuture(this)||invalidContext("Future#ap",this),isFuture(other)||invalidFuture("Future#ap",0,other),this._ap(other)},Future.prototype.map=function(mapper){return isFuture(this)||invalidContext("Future#map",this),isFunction(mapper)||invalidArgument("Future#map",0,"to be a Function",mapper),this._map(mapper)},Future.prototype.bimap=function(lmapper,rmapper){return isFuture(this)||invalidContext("Future#bimap",this),isFunction(lmapper)||invalidArgument("Future#bimap",0,"to be a Function",lmapper),isFunction(rmapper)||invalidArgument("Future#bimap",1,"to be a Function",rmapper),this._bimap(lmapper,rmapper)},Future.prototype.chain=function(mapper){return isFuture(this)||invalidContext("Future#chain",this),isFunction(mapper)||invalidArgument("Future#chain",0,"to be a Function",mapper),this._chain(mapper)},Future.prototype.mapRej=function(mapper){return isFuture(this)||invalidContext("Future#mapRej",this),isFunction(mapper)||invalidArgument("Future#mapRej",0,"to be a Function",mapper),this._mapRej(mapper)},Future.prototype.chainRej=function(mapper){return isFuture(this)||invalidContext("Future#chainRej",this),isFunction(mapper)||invalidArgument("Future#chainRej",0,"to be a Function",mapper),this._chainRej(mapper)},Future.prototype.race=function(other){return isFuture(this)||invalidContext("Future#race",this),isFuture(other)||invalidFuture("Future#race",0,other),this._race(other)},Future.prototype.both=function(other){return isFuture(this)||invalidContext("Future#both",this),isFuture(other)||invalidFuture("Future#both",0,other),this._both(other)},Future.prototype.and=function(other){return isFuture(this)||invalidContext("Future#and",this),isFuture(other)||invalidFuture("Future#and",0,other),this._and(other)},Future.prototype.or=function(other){return isFuture(this)||invalidContext("Future#or",this),isFuture(other)||invalidFuture("Future#or",0,other),this._or(other)},Future.prototype.swap=function(){return isFuture(this)||invalidContext("Future#ap",this),this._swap()},Future.prototype.fold=function(lmapper,rmapper){return isFuture(this)||invalidContext("Future#ap",this),isFunction(lmapper)||invalidArgument("Future#fold",0,"to be a Function",lmapper),isFunction(rmapper)||invalidArgument("Future#fold",1,"to be a Function",rmapper),this._fold(lmapper,rmapper)},Future.prototype.finally=function(other){return isFuture(this)||invalidContext("Future#finally",this),isFuture(other)||invalidFuture("Future#finally",0,other),this._finally(other)},Future.prototype.lastly=function(other){return isFuture(this)||invalidContext("Future#lastly",this),isFuture(other)||invalidFuture("Future#lastly",0,other),this._finally(other)},Future.prototype.fork=function(rej,res){return isFuture(this)||invalidContext("Future#fork",this),isFunction(rej)||invalidArgument("Future#fork",0,"to be a Function",rej),isFunction(res)||invalidArgument("Future#fork",0,"to be a Function",res),this._fork(rej,res)},Future.prototype.value=function(res){return isFuture(this)||invalidContext("Future#value",this),isFunction(res)||invalidArgument("Future#value",0,"to be a Function",res),this._fork(throwRejection,res)},Future.prototype.promise=function(){var this$1=this;return new Promise(function(res,rej){return this$1._fork(rej,res)})},Future.prototype.isRejected=function(){return!1},Future.prototype.isResolved=function(){return!1},Future.prototype.isSettled=function(){return this.isRejected()||this.isResolved()},Future.prototype.extractLeft=function(){return[]},Future.prototype.extractRight=function(){return[]};var Core=Object.create(Future.prototype);Core._ap=function(other){return new Sequence(this,[new ApAction(other)])},Core._map=function(mapper){return new Sequence(this,[new MapAction(mapper)])},Core._bimap=function(lmapper,rmapper){return new Sequence(this,[new BimapAction(lmapper,rmapper)])},Core._chain=function(mapper){return new Sequence(this,[new ChainAction(mapper)])},Core._mapRej=function(mapper){return new Sequence(this,[new MapRejAction(mapper)])},Core._chainRej=function(mapper){return new Sequence(this,[new ChainRejAction(mapper)])},Core._race=function(other){return new Sequence(this,[new RaceAction(other)])},Core._both=function(other){return new Sequence(this,[new BothAction(other)])},Core._and=function(other){return new Sequence(this,[new AndAction(other)])},Core._or=function(other){return new Sequence(this,[new OrAction(other)])},Core._swap=function(){return new Sequence(this,[new SwapAction])},Core._fold=function(lmapper,rmapper){return new Sequence(this,[new FoldAction(lmapper,rmapper)])},Core._finally=function(other){return new Sequence(this,[new FinallyAction(other)])},Computation.prototype=Object.create(Core),Computation.prototype._fork=function(rej,res){var open=!0,f=this._computation(function(x){open&&(open=!1,rej(x))},function(x){open&&(open=!1,res(x))});return check$fork(f,this._computation),function(){open&&f&&f(),open=!1}},Computation.prototype.toString=function(){return"Future("+showf(this._computation)+")"},Rejected.prototype=Object.create(Core),Rejected.prototype._ap=moop,Rejected.prototype._map=moop,Rejected.prototype._chain=moop,Rejected.prototype._race=moop,Rejected.prototype._both=moop,Rejected.prototype._and=moop,Rejected.prototype._or=function(other){return other},Rejected.prototype._finally=function(other){return other._and(this)},Rejected.prototype._swap=function(){return new Resolved(this._value)},Rejected.prototype._fork=function(rej){return rej(this._value),noop},Rejected.prototype.isRejected=function(){return!0},Rejected.prototype.extractLeft=function(){return[this._value]},Rejected.prototype.toString=function(){return"Future.reject("+show(this._value)+")"};var reject=function(x){return new Rejected(x)};Resolved.prototype=Object.create(Core),Resolved.prototype._race=moop,Resolved.prototype._mapRej=moop,Resolved.prototype._or=moop,Resolved.prototype._and=function(other){return other},Resolved.prototype._both=function(other){var this$1=this;return other._map(function(x){return[this$1._value,x]})},Resolved.prototype._swap=function(){return new Rejected(this._value)},Resolved.prototype._finally=function(other){var this$1=this;return other._map(function(){return this$1._value})},Resolved.prototype._fork=function(rej,res){return res(this._value),noop},Resolved.prototype.isResolved=function(){return!0},Resolved.prototype.extractRight=function(){return[this._value]},Resolved.prototype.toString=function(){return"Future.of("+show(this._value)+")"};var of=function(x){return new Resolved(x)};Never.prototype=Object.create(Future.prototype),Never.prototype._ap=moop,Never.prototype._map=moop,Never.prototype._bimap=moop,Never.prototype._chain=moop,Never.prototype._mapRej=moop,Never.prototype._chainRej=moop,Never.prototype._both=moop,Never.prototype._or=moop,Never.prototype._swap=moop,Never.prototype._fold=moop,Never.prototype._finally=moop,Never.prototype._race=function(other){return other},Never.prototype._fork=function(){return noop},Never.prototype.toString=function(){return"Future.never"};var never=new Never,isNever=function(x){return x===never};Eager.prototype=Object.create(Core),Eager.prototype._fork=function(rej,res){return this.rejected?rej(this.value):this.resolved?res(this.value):(this.rej=rej,this.res=res),this.cancel};var Action=function(){};Action.prototype.rejected=function(x){return new Rejected(x)},Action.prototype.resolved=function(x){return new Resolved(x)},Action.prototype.run=function(){return this},Action.prototype.cancel=function(){};var check$ap=function(f){return isFunction(f)?f:typeError("Future#ap expects its first argument to be a Future of a Function\n Actual: Future.of("+show(f)+")")},ApAction=function(Action){function ApAction(other){Action.call(this),this.other=other}return Action&&(ApAction.__proto__=Action),ApAction.prototype=Object.create(Action&&Action.prototype),ApAction.prototype.constructor=ApAction,ApAction.prototype.resolved=function(f){return check$ap(f),this.other._map(function(x){return f(x)})},ApAction.prototype.toString=function(){return"ap("+this.other.toString()+")"},ApAction}(Action),MapAction=function(Action){function MapAction(mapper){Action.call(this),this.mapper=mapper}return Action&&(MapAction.__proto__=Action),MapAction.prototype=Object.create(Action&&Action.prototype),MapAction.prototype.constructor=MapAction,MapAction.prototype.resolved=function(x){return new Resolved(this.mapper(x))},MapAction.prototype.toString=function(){return"map("+showf(this.mapper)+")"},MapAction}(Action),BimapAction=function(Action){function BimapAction(lmapper,rmapper){Action.call(this),this.lmapper=lmapper,this.rmapper=rmapper}return Action&&(BimapAction.__proto__=Action),BimapAction.prototype=Object.create(Action&&Action.prototype),BimapAction.prototype.constructor=BimapAction,BimapAction.prototype.rejected=function(x){return new Rejected(this.lmapper(x))},BimapAction.prototype.resolved=function(x){return new Resolved(this.rmapper(x))},BimapAction.prototype.toString=function(){return"bimap("+showf(this.lmapper)+", "+showf(this.rmapper)+")"},BimapAction}(Action),check$chain=function(m,f,x){return isFuture(m)?m:invalidFuture("Future#chain","the function its given to return a Future",m,"\n From calling: "+showf(f)+"\n With: "+show(x))},ChainAction=function(Action){function ChainAction(mapper){Action.call(this),this.mapper=mapper}return Action&&(ChainAction.__proto__=Action),ChainAction.prototype=Object.create(Action&&Action.prototype),ChainAction.prototype.constructor=ChainAction,ChainAction.prototype.resolved=function(x){return check$chain(this.mapper(x),this.mapper,x)},ChainAction.prototype.toString=function(){return"chain("+showf(this.mapper)+")"},ChainAction}(Action),MapRejAction=function(Action){function MapRejAction(mapper){Action.call(this),this.mapper=mapper}return Action&&(MapRejAction.__proto__=Action),MapRejAction.prototype=Object.create(Action&&Action.prototype),MapRejAction.prototype.constructor=MapRejAction,MapRejAction.prototype.rejected=function(x){return new Rejected(this.mapper(x))},MapRejAction.prototype.toString=function(){return"mapRej("+showf(this.mapper)+")"},MapRejAction}(Action),check$chainRej=function(m,f,x){return isFuture(m)?m:invalidFuture("Future#chainRej","the function its given to return a Future",m,"\n From calling: "+showf(f)+"\n With: "+show(x))},ChainRejAction=function(Action){function ChainRejAction(mapper){Action.call(this),this.mapper=mapper}return Action&&(ChainRejAction.__proto__=Action),ChainRejAction.prototype=Object.create(Action&&Action.prototype),ChainRejAction.prototype.constructor=ChainRejAction,ChainRejAction.prototype.rejected=function(x){return check$chainRej(this.mapper(x),this.mapper,x)},ChainRejAction.prototype.toString=function(){return"chainRej("+showf(this.mapper)+")"},ChainRejAction}(Action),SwapAction=function(Action){function SwapAction(){return Action.call(this),SwapAction.instance||(SwapAction.instance=this)}return Action&&(SwapAction.__proto__=Action),SwapAction.prototype=Object.create(Action&&Action.prototype),SwapAction.prototype.constructor=SwapAction,SwapAction.prototype.rejected=function(x){return new Resolved(x)},SwapAction.prototype.resolved=function(x){return new Rejected(x)},SwapAction.prototype.toString=function(){return"swap()"},SwapAction}(Action),FoldAction=function(Action){function FoldAction(lmapper,rmapper){Action.call(this),this.lmapper=lmapper,this.rmapper=rmapper}return Action&&(FoldAction.__proto__=Action),FoldAction.prototype=Object.create(Action&&Action.prototype),FoldAction.prototype.constructor=FoldAction,FoldAction.prototype.rejected=function(x){return new Resolved(this.lmapper(x))},FoldAction.prototype.resolved=function(x){return new Resolved(this.rmapper(x))},FoldAction.prototype.toString=function(){return"fold("+showf(this.lmapper)+", "+showf(this.rmapper)+")"},FoldAction}(Action),FinallyAction=function(Action){function FinallyAction(other){Action.call(this),this.other=other}return Action&&(FinallyAction.__proto__=Action),FinallyAction.prototype=Object.create(Action&&Action.prototype),FinallyAction.prototype.constructor=FinallyAction,FinallyAction.prototype.cancel=function(){this.other._fork(noop,noop)()},FinallyAction.prototype.rejected=function(x){return this.other._and(new Rejected(x))},FinallyAction.prototype.resolved=function(x){return this.other._map(function(){return x})},FinallyAction.prototype.toString=function(){return"finally("+this.other.toString()+")"},FinallyAction}(Action),AndAction=function(Action){function AndAction(other){Action.call(this),this.other=other}return Action&&(AndAction.__proto__=Action),AndAction.prototype=Object.create(Action&&Action.prototype),AndAction.prototype.constructor=AndAction,AndAction.prototype.resolved=function(){return this.other},AndAction.prototype.toString=function(){return"and("+this.other.toString()+")"},AndAction}(Action),OrAction=function(Action){function OrAction(other){Action.call(this),this.other=other}return Action&&(OrAction.__proto__=Action),OrAction.prototype=Object.create(Action&&Action.prototype),OrAction.prototype.constructor=OrAction,OrAction.prototype.rejected=function(){return this.other},OrAction.prototype.toString=function(){return"or("+this.other.toString()+")"},OrAction}(Action),RaceAction=function(Action){function RaceAction(other){Action.call(this),this.other=other}return Action&&(RaceAction.__proto__=Action),RaceAction.prototype=Object.create(Action&&Action.prototype),RaceAction.prototype.constructor=RaceAction,RaceAction.prototype.run=function(early){return new RaceActionState(early,this.other)},RaceAction.prototype.toString=function(){return"race("+this.other.toString()+")"},RaceAction}(Action),RaceActionState=function(RaceAction){function RaceActionState(early,other){var this$1=this;RaceAction.call(this,other),this.cancel=other._fork(function(x){return early(new Rejected(x),this$1)},function(x){return early(new Resolved(x),this$1)})}return RaceAction&&(RaceActionState.__proto__=RaceAction),RaceActionState.prototype=Object.create(RaceAction&&RaceAction.prototype),RaceActionState.prototype.constructor=RaceActionState,RaceActionState.prototype.rejected=function(x){return this.cancel(),new Rejected(x)},RaceActionState.prototype.resolved=function(x){return this.cancel(),new Resolved(x)},RaceActionState}(RaceAction),BothAction=function(Action){function BothAction(other){Action.call(this),this.other=other}return Action&&(BothAction.__proto__=Action),BothAction.prototype=Object.create(Action&&Action.prototype),BothAction.prototype.constructor=BothAction,BothAction.prototype.run=function(early){return new BothActionState(early,this.other)},BothAction.prototype.resolved=function(x){return this.other._map(function(y){return[x,y]})},BothAction.prototype.toString=function(){return"both("+this.other.toString()+")"},BothAction}(Action),BothActionState=function(BothAction){
function BothActionState(early,other){var this$1=this;BothAction.call(this,new Eager(other)),this.cancel=this.other.fork(function(x){return early(new Rejected(x),this$1)},noop)}return BothAction&&(BothActionState.__proto__=BothAction),BothActionState.prototype=Object.create(BothAction&&BothAction.prototype),BothActionState.prototype.constructor=BothActionState,BothActionState}(BothAction);Sequence.prototype=Object.create(Future.prototype),Sequence.prototype._transform=function(action){return new Sequence(this._spawn,this._actions.concat([action]))},Sequence.prototype._ap=function(other){return this._transform(new ApAction(other))},Sequence.prototype._map=function(mapper){return this._transform(new MapAction(mapper))},Sequence.prototype._bimap=function(lmapper,rmapper){return this._transform(new BimapAction(lmapper,rmapper))},Sequence.prototype._chain=function(mapper){return this._transform(new ChainAction(mapper))},Sequence.prototype._mapRej=function(mapper){return this._transform(new MapRejAction(mapper))},Sequence.prototype._chainRej=function(mapper){return this._transform(new ChainRejAction(mapper))},Sequence.prototype._race=function(other){return isNever(other)?this:this._transform(new RaceAction(other))},Sequence.prototype._both=function(other){return this._transform(new BothAction(other))},Sequence.prototype._and=function(other){return this._transform(new AndAction(other))},Sequence.prototype._or=function(other){return this._transform(new OrAction(other))},Sequence.prototype._swap=function(){return this._transform(new SwapAction)},Sequence.prototype._fold=function(lmapper,rmapper){return this._transform(new FoldAction(lmapper,rmapper))},Sequence.prototype._finally=function(other){return this._transform(new FinallyAction(other))},Sequence.prototype._fork=function(rej,res){function settle(m){if(settled=!0,(future=m)instanceof Sequence){for(var i=future._actions.length-1;i>=0;i--)stack.unshift(future._actions[i]);future=future._spawn}}function early(m,terminator){if(cancel(),action!==terminator)for(action.cancel();(it=queue.shift())&&it!==terminator;)it.cancel();settle(m),async&&drain()}function rejected(x){settle(action.rejected(x)),async&&drain()}function resolved(x){settle(action.resolved(x)),async&&drain()}function drain(){for(async=!1;action=stack.shift()||queue.shift();)if(settled=!1,cancel=future._fork(rejected,resolved),!settled&&(action=action.run(early),!settled)){for(;it=stack.shift();){var tmp=it.run(early);if(settled)break;queue.push(tmp)}if(!settled)return void(async=!0)}cancel=future._fork(rej,res)}var action,it,settled,async,stack=new Denque(this._actions),queue=new Denque(this._actions.length),cancel=noop,future=this._spawn;return drain(),function(){for(cancel(),action&&action.cancel();it=queue.shift();)it.cancel();stack.clear(),cancel=noop}},Sequence.prototype.toString=function(){return""+this._spawn.toString()+this._actions.map(function(x){return"."+x.toString()}).join("")},Future["@@type"]=$$type,Future[FL.of]=of;var dispatchers=Object.freeze({ap:ap,map:map,bimap:bimap,chain:chain,mapRej:mapRej,chainRej:chainRej,lastly:lastly,finally:lastly,and:and,both:both,or:or,race:race,swap:swap,fold:fold,fork:fork,promise:promise,value:value,extractLeft:extractLeft,extractRight:extractRight});After.prototype=Object.create(Core),After.prototype._race=After$race,After.prototype._swap=function(){return new RejectAfter(this._time,this._value)},After.prototype._fork=function(rej,res){var id=setTimeout(res,this._time,this._value);return function(){clearTimeout(id)}},After.prototype.extractRight=function(){return[this._value]},After.prototype.toString=function(){return"Future.after("+show(this._time)+", "+show(this._value)+")"},RejectAfter.prototype=Object.create(Core),RejectAfter.prototype._race=After$race,RejectAfter.prototype._swap=function(){return new After(this._time,this._value)},RejectAfter.prototype._fork=function(rej){var id=setTimeout(rej,this._time,this._value);return function(){clearTimeout(id)}},RejectAfter.prototype.extractLeft=function(){return[this._value]},RejectAfter.prototype.toString=function(){return"Future.rejectAfter("+show(this._time)+", "+show(this._value)+")"},Attempt.prototype=Object.create(Core),Attempt.prototype._fork=function(rej,res){var r;try{r=this._fn()}catch(e){return rej(e),noop}return res(r),noop},Attempt.prototype.toString=function(){return"Future.try("+showf(this._fn)+")"};var Cold=Cached.Cold=0,Pending=Cached.Pending=1,Rejected$1=Cached.Rejected=2,Resolved$1=Cached.Resolved=3;Cached.prototype=Object.create(Core),Cached.prototype.isRejected=function(){return this._state===Rejected$1},Cached.prototype.isResolved=function(){return this._state===Resolved$1},Cached.prototype.extractLeft=function(){return this.isRejected()?[this._value]:[]},Cached.prototype.extractRight=function(){return this.isResolved()?[this._value]:[]},Cached.prototype._addToQueue=function(rej,res){var _this=this;if(_this._state>Pending)return noop;var i=_this._queue.push(new Queued(rej,res))-1;return _this._queued=_this._queued+1,function(){_this._state>Pending||(_this._queue[i]=void 0,_this._queued=_this._queued-1,0===_this._queued&&_this.reset())}},Cached.prototype._drainQueue=function(){if(!(this._state<=Pending)&&0!==this._queued){for(var queue=this._queue,length=queue.length,state=this._state,value=this._value,i=0;i<length;i++)queue[i]&&queue[i][state](value),queue[i]=void 0;this._queue=void 0,this._queued=0}},Cached.prototype.reject=function(reason){this._state>Pending||(this._value=reason,this._state=Rejected$1,this._drainQueue())},Cached.prototype.resolve=function(value){this._state>Pending||(this._value=value,this._state=Resolved$1,this._drainQueue())},Cached.prototype.run=function(){var _this=this;_this._state>Cold||(_this._state=Pending,_this._cancel=_this._pure._fork(function(x){_this.reject(x)},function(x){_this.resolve(x)}))},Cached.prototype.reset=function(){this._state!==Cold&&(this._state>Pending&&this._cancel(),this._cancel=noop,this._queue=[],this._queued=0,this._value=void 0,this._state=Cold)},Cached.prototype._fork=function(rej,res){var cancel=noop;switch(this._state){case Pending:cancel=this._addToQueue(rej,res);break;case Rejected$1:rej(this._value);break;case Resolved$1:res(this._value);break;default:cancel=this._addToQueue(rej,res),this.run()}return cancel},Cached.prototype.toString=function(){return"Future.cache("+this._pure.toString()+")"};var Next=function(x){return{done:!1,value:x}},Done=function(x){return{done:!0,value:x}},isIteration=function(x){return isObject(x)&&isBoolean(x.done)},Undetermined=0,Synchronous=1,Asynchronous=2;ChainRec.prototype=Object.create(Core),ChainRec.prototype._fork=function(rej,res){function resolved(it){state=it,timing=timing===Undetermined?Synchronous:drain()}function drain(){for(;!state.done;){timing=Undetermined;var m=_step(Next,Done,state.value);if(cancel=m._fork(rej,resolved),timing!==Synchronous)return void(timing=Asynchronous)}res(state.value)}var ref=this,_step=ref._step,_init=ref._init,timing=Undetermined,cancel=noop,state=Next(_init);return drain(),function(){cancel()}},ChainRec.prototype.toString=function(){return"Future.chainRec("+showf(this._step)+", "+show(this._init)+")"},Future[FL.chainRec]=chainRec,Encase.prototype=Object.create(Core),Encase.prototype._fork=function(rej,res){var r;try{r=this._fn(this._a)}catch(e){return rej(e),noop}return res(r),noop},Encase.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a;return"Future.encase("+showf(_fn)+", "+show(_a)+")"},Encase2.prototype=Object.create(Core),Encase2.prototype._fork=function(rej,res){var r;try{r=this._fn(this._a,this._b)}catch(e){return rej(e),noop}return res(r),noop},Encase2.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b;return"Future.encase2("+showf(_fn)+", "+show(_a)+", "+show(_b)+")"},Encase3.prototype=Object.create(Core),Encase3.prototype._fork=function(rej,res){var r;try{r=this._fn(this._a,this._b,this._c)}catch(e){return rej(e),noop}return res(r),noop},Encase3.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b,_c=ref._c;return"Future.encase3("+showf(_fn)+", "+show(_a)+", "+show(_b)+", "+show(_c)+")"},EncaseN.prototype=Object.create(Core),EncaseN.prototype._fork=function(rej,res){var open=!0;return this._fn(this._a,function(err,val){open&&(open=!1,err?rej(err):res(val))}),function(){open=!1}},EncaseN.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a;return"Future.encaseN("+showf(_fn)+", "+show(_a)+")"},EncaseN2.prototype=Object.create(Core),EncaseN2.prototype._fork=function(rej,res){var open=!0;return this._fn(this._a,this._b,function(err,val){open&&(open=!1,err?rej(err):res(val))}),function(){open=!1}},EncaseN2.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b;return"Future.encaseN2("+showf(_fn)+", "+show(_a)+", "+show(_b)+")"},EncaseN$1.prototype=Object.create(Core),EncaseN$1.prototype._fork=function(rej,res){var open=!0;return this._fn(this._a,this._b,this._c,function(err,val){open&&(open=!1,err?rej(err):res(val))}),function(){open=!1}},EncaseN$1.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b,_c=ref._c;return"Future.encaseN3("+showf(_fn)+", "+show(_a)+", "+show(_b)+", "+show(_c)+")"},EncaseP.prototype=Object.create(Core),EncaseP.prototype._fork=function(rej,res){var ref=this,_fn=ref._fn,_a=ref._a;return check$promise(_fn(_a),_fn,_a).then(escapeTick(res),escapeTick(rej)),noop},EncaseP.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a;return"Future.encaseP("+showf(_fn)+", "+show(_a)+")"},EncaseP2.prototype=Object.create(Core),EncaseP2.prototype._fork=function(rej,res){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b;return check$promise$1(_fn(_a,_b),_fn,_a,_b).then(escapeTick(res),escapeTick(rej)),noop},EncaseP2.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b;return"Future.encaseP2("+showf(_fn)+", "+show(_a)+", "+show(_b)+")"},EncaseP3.prototype=Object.create(Core),EncaseP3.prototype._fork=function(rej,res){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b,_c=ref._c;return check$promise$2(_fn(_a,_b,_c),_fn,_a,_b,_c).then(escapeTick(res),escapeTick(rej)),noop},EncaseP3.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b,_c=ref._c;return"Future.encaseP3("+show(_fn)+", "+show(_a)+", "+show(_b)+", "+show(_c)+")"};var check$iterator=function(g){return isIterator(g)?g:invalidArgument("Future.do",0,'return an iterator, maybe you forgot the "*"',g)},check$iteration=function(o){return isIteration(o)||typeError("Future.do was given an invalid generator: Its iterator did not return a valid iteration from iterator.next()\n Actual: "+show(o)),o.done||isFuture(o.value)?o:invalidFuture("Future.do","the iterator to produce only valid Futures",o.value,"\n Tip: If you're using a generator, make sure you always yield a Future")};Go.prototype=Object.create(Core),Go.prototype._fork=function(rej,res){function resolved(x){if(value=x,timing===Asynchronous)return drain();timing=Synchronous,state=check$iteration(iterator.next(value))}function drain(){for(state=check$iteration(iterator.next(value));!state.done;)if(timing=Undetermined,cancel=state.value._fork(rej,resolved),timing!==Synchronous)return void(timing=Asynchronous);res(state.value)}var state,value,iterator=check$iterator(this._generator()),timing=Undetermined,cancel=noop;return drain(),function(){cancel()}},Go.prototype.toString=function(){return"Future.do("+showf(this._generator)+")"},Hook.prototype=Object.create(Core),Hook.prototype._fork=function(rej,res){function Hook$done(){cont(value)}function Hook$dispose(){var disposal=_dispose(resource);return check$dispose(disposal,_dispose,resource),cancel=disposal._fork(rej,Hook$done)}function Hook$cancelConsuption(){cancelConsume(),Hook$dispose()()}function Hook$consumptionRejected(x){cont=rej,value=x,Hook$dispose()}function Hook$consumptionResolved(x){cont=res,value=x,Hook$dispose()}function Hook$acquireResolved(x){resource=x;var consumption=_consume(resource);check$consume(consumption,_consume,resource),cancel=Hook$cancelConsuption,cancelConsume=consumption._fork(Hook$consumptionRejected,Hook$consumptionResolved)}var cancel,resource,value,ref=this,_acquire=ref._acquire,_dispose=ref._dispose,_consume=ref._consume,cancelAcquire=noop,cancelConsume=noop,cont=noop;return cancelAcquire=_acquire._fork(rej,Hook$acquireResolved),cancel=cancel||cancelAcquire,function(){cancel()}},Hook.prototype.toString=function(){var ref=this,_acquire=ref._acquire,_dispose=ref._dispose,_consume=ref._consume;return"Future.hook("+_acquire.toString()+", "+showf(_dispose)+", "+showf(_consume)+")"},Node.prototype=Object.create(Core),Node.prototype._fork=function(rej,res){var open=!0;return this._fn(function(err,val){open&&(open=!1,err?rej(err):res(val))}),function(){open=!1}},Node.prototype.toString=function(){var ref=this,_fn=ref._fn;return"Future.node("+showf(_fn)+")"},ParallelAp.prototype=Object.create(Core),ParallelAp.prototype._fork=function(rej,res){function ParallelAp$rej(x){rejected||(rejected=!0,rej(x))}var func,val,c1,c2,okval=!1,okfunc=!1,rejected=!1;return c1=this._mval._fork(ParallelAp$rej,function(x){if(c1=noop,!okval)return okfunc=!0,void(val=x);res(func(x))}),c2=this._mfunc._fork(ParallelAp$rej,function(f){if(c2=noop,check$ap$f(f),!okfunc)return okval=!0,void(func=f);res(f(val))}),function(){c1(),c2()}},ParallelAp.prototype.toString=function(){return"new ParallelAp("+this._mval.toString()+", "+this._mfunc.toString()+")"};var Par=concurrify(Future,never,race,function(mval,mfunc){return new ParallelAp(mval,mfunc)}),check$parallel=function(m,i){return isFuture(m)?m:invalidFuture("Future.parallel","its second argument to be an array of valid Futures. The value at position "+i+" in the array is not a Future",m)};Parallel.prototype=Object.create(Core),Parallel.prototype._fork=function(rej,res){function Parallel$fork$cancelAll(){for(var n=0;n<_max;n++)cancels[n]&&cancels[n]()}function Parallel$fork$rej(reason){Parallel$fork$cancelAll(),rej(reason)}function Parallel$fork$run(future,idx,cancelSlot){cancels[cancelSlot]=future._fork(Parallel$fork$rej,function(value){out[idx]=value,i<_length?Parallel$fork$run(_futures[i],i++,cancelSlot):++i-_max===_length&&res(out)})}for(var ref=this,_futures=ref._futures,_length=ref._length,_max=ref._max,cancels=new Array(_max),out=new Array(_length),i=_max,n=0;n<_max;n++)Parallel$fork$run(_futures[n],n,n);return Parallel$fork$cancelAll},Parallel.prototype.toString=function(){return"Future.parallel("+this._max+", "+show(this._futures)+")"};var emptyArray=new Resolved([]);return TryP.prototype=Object.create(Core),TryP.prototype._fork=function(rej,res){var ref=this,_fn=ref._fn;return check$promise$3(_fn(),_fn).then(escapeTick(res),escapeTick(rej)),noop},TryP.prototype.toString=function(){var ref=this,_fn=ref._fn;return"Future.tryP("+show(_fn)+")"},"function"!=typeof Object.create&&error("Please polyfill Object.create to use Fluture"),"function"!=typeof Object.assign&&error("Please polyfill Object.assign to use Fluture"),"function"!=typeof Array.isArray&&error("Please polyfill Array.isArray to use Fluture"),Object.assign(Future,dispatchers,{Future:Future,after:after,attempt:attempt,cache:cache,chainRec:chainRec,do:go,encase:encase,encase2:encase2,encase3:encase3,encaseN:encaseN,encaseN2:encaseN2,encaseN3:encaseN3,encaseP:encaseP,encaseP2:encaseP2,encaseP3:encaseP3,go:go,hook:hook,isFuture:isFuture,isNever:isNever,never:never,node:node,of:of,Par:Par,parallel:parallel,reject:reject,rejectAfter:rejectAfter,seq:seq,try:attempt,tryP:tryP})});
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?module.exports=factory(require("denque"),require("sanctuary-type-classes"),require("inspect-f"),require("sanctuary-type-identifiers"),require("concurrify")):"function"==typeof define&&define.amd?define(["denque","sanctuary-type-classes","inspect-f","sanctuary-type-identifiers","concurrify"],factory):global.Fluture=factory(global.Denque,global.sanctuaryTypeClasses,global.inspectf,global.sanctuaryTypeIdentifiers,global.concurrify)}(this,function(Denque,Z,inspectf,type,concurrify){"use strict";function Future$1(computation){return isFunction(computation)||invalidArgument("Future",0,"be a Function",computation),new Computation(computation)}function isFuture(x){return x instanceof Future$1||type(x)===$$type}function check$fork(f,c){void 0===f||isFunction(f)&&0===f.length||typeError("Future expected its computation to return a nullary function or void\n Actual: "+show(f)+"\n From calling: "+showf(c))}function Computation(computation){this._computation=computation}function Rejected(value){this._value=value}function Resolved(value){this._value=value}function Never(){}function Eager(future){var this$1=this;this.rej=noop,this.res=noop,this.rejected=!1,this.resolved=!1,this.value=null,this.cancel=future._fork(function(x){this$1.value=x,this$1.rejected=!0,this$1.cancel=noop,this$1.rej(x)},function(x){this$1.value=x,this$1.resolved=!0,this$1.cancel=noop,this$1.res(x)})}function Sequence(spawn,actions){void 0===actions&&(actions=[]),this._spawn=spawn,this._actions=actions}function ChainRec(step,init){this._step=step,this._init=init}function chainRec(step,init){return new ChainRec(step,init)}function ap$mval(mval,mfunc){return Z.Apply.test(mfunc)||invalidArgument("Future.ap",1,"be an Apply",mfunc),Z.ap(mval,mfunc)}function ap(mval,mfunc){return Z.Apply.test(mval)||invalidArgument("Future.ap",0,"be an Apply",mval),1===arguments.length?partial1(ap$mval,mval):ap$mval(mval,mfunc)}function map$mapper(mapper,m){return Z.Functor.test(m)||invalidArgument("Future.map",1,"be a Functor",m),Z.map(mapper,m)}function map(mapper,m){return isFunction(mapper)||invalidArgument("Future.map",0,"be a Function",mapper),1===arguments.length?partial1(map$mapper,mapper):map$mapper(mapper,m)}function bimap$lmapper$rmapper(lmapper,rmapper,m){return Z.Bifunctor.test(m)||invalidArgument("Future.bimap",2,"be a Bifunctor",m),Z.bimap(lmapper,rmapper,m)}function bimap$lmapper(lmapper,rmapper,m){return isFunction(rmapper)||invalidArgument("Future.bimap",1,"be a Function",rmapper),2===arguments.length?partial2(bimap$lmapper$rmapper,lmapper,rmapper):bimap$lmapper$rmapper(lmapper,rmapper,m)}function bimap(lmapper,rmapper,m){return isFunction(lmapper)||invalidArgument("Future.bimap",0,"be a Function",lmapper),1===arguments.length?partial1(bimap$lmapper,lmapper):2===arguments.length?bimap$lmapper(lmapper,rmapper):bimap$lmapper(lmapper,rmapper,m)}function chain$chainer(chainer,m){return Z.Chain.test(m)||invalidArgument("Future.chain",1,"be a Chain",m),Z.chain(chainer,m)}function chain(chainer,m){return isFunction(chainer)||invalidArgument("Future.chain",0,"be a Function",chainer),1===arguments.length?partial1(chain$chainer,chainer):chain$chainer(chainer,m)}function mapRej$mapper(mapper,m){return isFuture(m)||invalidFuture("Future.mapRej",1,m),m.mapRej(mapper)}function mapRej(mapper,m){return isFunction(mapper)||invalidArgument("Future.mapRej",0,"be a Function",mapper),1===arguments.length?partial1(mapRej$mapper,mapper):mapRej$mapper(mapper,m)}function chainRej$chainer(chainer,m){return isFuture(m)||invalidFuture("Future.chainRej",1,m),m.chainRej(chainer)}function chainRej(chainer,m){return isFunction(chainer)||invalidArgument("Future.chainRej",0,"be a Function",chainer),1===arguments.length?partial1(chainRej$chainer,chainer):chainRej$chainer(chainer,m)}function lastly$right(right,left){return isFuture(left)||invalidFuture("Future.finally",1,left),left.finally(right)}function lastly(right,left){return isFuture(right)||invalidFuture("Future.finally",0,right),1===arguments.length?partial1(lastly$right,right):lastly$right(right,left)}function and$left(left,right){return isFuture(right)||invalidFuture("Future.and",1,right),left.and(right)}function and(left,right){return isFuture(left)||invalidFuture("Future.and",0,left),1===arguments.length?partial1(and$left,left):and$left(left,right)}function both$left(left,right){return isFuture(right)||invalidFuture("Future.both",1,right),left.both(right)}function both(left,right){return isFuture(left)||invalidFuture("Future.both",0,left),1===arguments.length?partial1(both$left,left):both$left(left,right)}function or$left(left,right){return isFuture(right)||invalidFuture("Future.or",1,right),left.or(right)}function or(left,right){return isFuture(left)||invalidFuture("Future.or",0,left),1===arguments.length?partial1(or$left,left):or$left(left,right)}function race$right(right,left){return isFuture(left)||invalidFuture("Future.race",1,left),left.race(right)}function race(right,left){return isFuture(right)||invalidFuture("Future.race",0,right),1===arguments.length?partial1(race$right,right):race$right(right,left)}function swap(m){return isFuture(m)||invalidFuture("Future.swap",0,m),m.swap()}function fold$f$g(f,g,m){return isFuture(m)||invalidFuture("Future.fold",2,m),m.fold(f,g)}function fold$f(f,g,m){return isFunction(g)||invalidArgument("Future.fold",1,"be a function",g),2===arguments.length?partial2(fold$f$g,f,g):fold$f$g(f,g,m)}function fold(f,g,m){return isFunction(f)||invalidArgument("Future.fold",0,"be a function",f),1===arguments.length?partial1(fold$f,f):2===arguments.length?fold$f(f,g):fold$f(f,g,m)}function fork$f$g(f,g,m){return isFuture(m)||invalidFuture("Future.fork",2,m),m._fork(f,g)}function fork$f(f,g,m){return isFunction(g)||invalidArgument("Future.fork",1,"be a function",g),2===arguments.length?partial2(fork$f$g,f,g):fork$f$g(f,g,m)}function fork(f,g,m){return isFunction(f)||invalidArgument("Future.fork",0,"be a function",f),1===arguments.length?partial1(fork$f,f):2===arguments.length?fork$f(f,g):fork$f(f,g,m)}function promise(m){return isFuture(m)||invalidFuture("Future.promise",0,m),m.promise()}function value$cont(cont,m){return isFuture(m)||invalidFuture("Future.value",1,m),m.value(cont)}function value(cont,m){return isFunction(cont)||invalidArgument("Future.value",0,"be a Function",cont),1===arguments.length?partial1(value$cont,cont):value$cont(cont,m)}function extractLeft(m){return isFuture(m)||invalidFuture("Future.extractLeft",0,m),m.extractLeft()}function extractRight(m){return isFuture(m)||invalidFuture("Future.extractRight",0,m),m.extractRight()}function After$race(other){return other.isSettled()?other:isNever(other)?this:other instanceof After||other instanceof RejectAfter?other._time<this._time?other:this:Core._race.call(this,other)}function After(time,value){this._time=time,this._value=value}function RejectAfter(time,value){this._time=time,this._value=value}function after$time(time,value){return time===1/0?never:new After(time,value)}function after(time,value){return isUnsigned(time)||invalidArgument("Future.after",0,"be a positive integer",time),1===arguments.length?partial1(after$time,time):after$time(time,value)}function rejectAfter$time(time,reason){return time===1/0?never:new RejectAfter(time,reason)}function rejectAfter(time,reason){return isUnsigned(time)||invalidArgument("Future.rejectAfter",0,"be a positive integer",time),1===arguments.length?partial1(rejectAfter$time,time):rejectAfter$time(time,reason)}function Attempt(fn){this._fn=fn}function attempt(f){return isFunction(f)||invalidArgument("Future.try",0,"be a function",f),new Attempt(f)}function Queued(rej,res){this[Rejected$1]=rej,this[Resolved$1]=res}function Cached(pure){this._pure=pure,this.reset()}function cache(m){return isFuture(m)||invalidFuture("Future.cache",0,m),new Cached(m)}function Encase(fn,a){this._fn=fn,this._a=a}function encase(f,x){return isFunction(f)||invalidArgument("Future.encase",0,"be a function",f),1===arguments.length?partial1(encase,f):new Encase(f,x)}function Encase2(fn,a,b){this._fn=fn,this._a=a,this._b=b}function encase2(f,x,y){switch(isFunction(f)||invalidArgument("Future.encase2",0,"be a function",f),arguments.length){case 1:return partial1(encase2,f);case 2:return partial2(encase2,f,x);default:return new Encase2(f,x,y)}}function Encase3(fn,a,b,c){this._fn=fn,this._a=a,this._b=b,this._c=c}function encase3(f,x,y,z){switch(isFunction(f)||invalidArgument("Future.encase3",0,"be a function",f),arguments.length){case 1:return partial1(encase3,f);case 2:return partial2(encase3,f,x);case 3:return partial3(encase3,f,x,y);default:return new Encase3(f,x,y,z)}}function EncaseN(fn,a){this._fn=fn,this._a=a}function encaseN(f,x){return isFunction(f)||invalidArgument("Future.encaseN",0,"be a function",f),1===arguments.length?partial1(encaseN,f):new EncaseN(f,x)}function EncaseN2(fn,a,b){this._fn=fn,this._a=a,this._b=b}function encaseN2(f,x,y){switch(isFunction(f)||invalidArgument("Future.encaseN2",0,"be a function",f),arguments.length){case 1:return partial1(encaseN2,f);case 2:return partial2(encaseN2,f,x);default:return new EncaseN2(f,x,y)}}function EncaseN$1(fn,a,b,c){this._fn=fn,this._a=a,this._b=b,this._c=c}function encaseN3(f,x,y,z){switch(isFunction(f)||invalidArgument("Future.encaseN3",0,"be a function",f),arguments.length){case 1:return partial1(encaseN3,f);case 2:return partial2(encaseN3,f,x);case 3:return partial3(encaseN3,f,x,y);default:return new EncaseN$1(f,x,y,z)}}function check$promise(p,f,a){return isThenable(p)?p:typeError("Future.encaseP expects the function it's given to return a Promise/Thenable\n Actual: "+show(p)+"\n From calling: "+showf(f)+"\n With: "+show(a))}function EncaseP(fn,a){this._fn=fn,this._a=a}function encaseP(f,x){return isFunction(f)||invalidArgument("Future.encaseP",0,"be a function",f),1===arguments.length?partial1(encaseP,f):new EncaseP(f,x)}function check$promise$1(p,f,a,b){return isThenable(p)?p:typeError("Future.encaseP2 expects the function it's given to return a Promise/Thenable\n Actual: "+show(p)+"\n From calling: "+showf(f)+"\n With 1: "+show(a)+"\n With 2: "+show(b))}function EncaseP2(fn,a,b){this._fn=fn,this._a=a,this._b=b}function encaseP2(f,x,y){switch(isFunction(f)||invalidArgument("Future.encaseP2",0,"be a function",f),arguments.length){case 1:return partial1(encaseP2,f);case 2:return partial2(encaseP2,f,x);default:return new EncaseP2(f,x,y)}}function check$promise$2(p,f,a,b,c){return isThenable(p)?p:typeError("Future.encaseP3 expects the function it's given to return a Promise/Thenable\n Actual: "+show(p)+"\n From calling: "+showf(f)+"\n With 1: "+show(a)+"\n With 2: "+show(b)+"\n With 3: "+show(c))}function EncaseP3(fn,a,b,c){this._fn=fn,this._a=a,this._b=b,this._c=c}function encaseP3(f,x,y,z){switch(isFunction(f)||invalidArgument("Future.encaseP3",0,"be a function",f),arguments.length){case 1:return partial1(encaseP3,f);case 2:return partial2(encaseP3,f,x);case 3:return partial3(encaseP3,f,x,y);default:return new EncaseP3(f,x,y,z)}}function Go(generator){this._generator=generator}function go(generator){return isFunction(generator)||invalidArgument("Future.do",0,"be a Function",generator),new Go(generator)}function check$dispose(m,f,x){isFuture(m)||invalidFuture("Future.hook","the first function it's given to return a Future",m,"\n From calling: "+showf(f)+"\n With: "+show(x))}function check$consume(m,f,x){isFuture(m)||invalidFuture("Future.hook","the second function it's given to return a Future",m,"\n From calling: "+showf(f)+"\n With: "+show(x))}function Hook(acquire,dispose,consume){this._acquire=acquire,this._dispose=dispose,this._consume=consume}function hook$acquire$cleanup(acquire,cleanup,consume){return isFunction(consume)||invalidArgument("Future.hook",2,"be a Future",consume),new Hook(acquire,cleanup,consume)}function hook$acquire(acquire,cleanup,consume){return isFunction(cleanup)||invalidArgument("Future.hook",1,"be a function",cleanup),2===arguments.length?partial2(hook$acquire$cleanup,acquire,cleanup):hook$acquire$cleanup(acquire,cleanup,consume)}function hook(acquire,cleanup,consume){return isFuture(acquire)||invalidFuture("Future.hook",0,acquire),1===arguments.length?partial1(hook$acquire,acquire):2===arguments.length?hook$acquire(acquire,cleanup):hook$acquire(acquire,cleanup,consume)}function Node(fn){this._fn=fn}function node(f){return isFunction(f)||invalidArgument("Future.node",0,"be a function",f),new Node(f)}function check$ap$f(f){isFunction(f)||typeError("Future#ap expects its first argument to be a Future of a Function\n Actual: Future.of("+show(f)+")")}function ParallelAp(mval,mfunc){this._mval=mval,this._mfunc=mfunc}function isParallel(x){return x instanceof Par||type(x)===Par["@@type"]}function seq(par){return isParallel(par)||invalidArgument("Future.seq",0,"to be a Par",par),par.sequential}function Parallel(max,futures){this._futures=futures,this._length=futures.length,this._max=Math.min(this._length,max)}function parallel$max(max,xs){isArray(xs)||invalidArgument("Future.parallel",1,"be an array",xs);var futures=mapArray(xs,check$parallel);return 0===futures.length?emptyArray:new Parallel(max,futures)}function parallel(max,xs){return isUnsigned(max)||invalidArgument("Future.parallel",0,"be a positive integer",max),1===arguments.length?partial1(parallel$max,max):parallel$max(max,xs)}function check$promise$3(p,f){return isThenable(p)?p:typeError("Future.tryP expects the function it's given to return a Promise/Thenable\n Actual: "+show(p)+"\n From calling: "+showf(f))}function TryP(fn){this._fn=fn}function tryP(f){return isFunction(f)||invalidArgument("Future.tryP",0,"be a function",f),new TryP(f)}Denque="default"in Denque?Denque.default:Denque,Z="default"in Z?Z.default:Z,inspectf="default"in inspectf?inspectf.default:inspectf,type="default"in type?type.default:type,concurrify="default"in concurrify?concurrify.default:concurrify;var noop=function(){},moop=function(){return this},show=Z.toString,padf=function(sf,s){return s.replace(/^/gm,sf).replace(sf,"")},showf=function(f){return padf(" ",inspectf(2,f))},mapArray=function(xs,f){for(var l=xs.length,ys=new Array(l),i=0;i<l;i++)ys[i]=f(xs[i],i,xs);return ys},partial1=function(f,a){return function(b,c,d){switch(arguments.length){case 1:return f(a,b);case 2:return f(a,b,c);default:return f(a,b,c,d)}}},partial2=function(f,a,b){return function(c,d){return 1===arguments.length?f(a,b,c):f(a,b,c,d)}},partial3=function(f,a,b,c){return function(d){return f(a,b,c,d)}},escapeTick=function(f){return function(x){setTimeout(function(){f(x)},0)}},isFunction=function(f){return"function"==typeof f},isThenable=function(m){return m instanceof Promise||Boolean(m)&&isFunction(m.then)},isBoolean=function(f){return"boolean"==typeof f},isNumber=function(f){return"number"==typeof f},isUnsigned=function(n){return n===1/0||isNumber(n)&&n>0&&n%1==0},isObject=function(o){return null!==o&&"object"==typeof o},isIterator=function(i){return isObject(i)&&isFunction(i.next)},isArray=Array.isArray,FL={map:"fantasy-land/map",bimap:"fantasy-land/bimap",chain:"fantasy-land/chain",chainRec:"fantasy-land/chainRec",ap:"fantasy-land/ap",of:"fantasy-land/of"},ordinal=["first","second","third","fourth","fifth"],$$type="fluture/Future@2",error=function(message){throw new Error(message)},typeError=function(message){throw new TypeError(message)},invalidArgument=function(it,at,expected,actual){return typeError(it+" expects its "+ordinal[at]+" argument to "+expected+"\n Actual: "+show(actual))},invalidContext=function(it,actual){return typeError(it+" was invoked outside the context of a Future. You might want to use a dispatcher instead\n Called on: "+show(actual))},invalidNamespace=function(m,x){return"The Future was not created by fluture. Make sure you transform other Futures to fluture Futures. Got "+(x?"a Future from "+x:"an unscoped Future")+".\n See: https://github.com/fluture-js/Fluture#casting-futures"},invalidVersion=function(m,x){return"The Future was created by "+(x<2?"an older":"a newer")+" version of fluture. This means that one of the sources which creates Futures is outdated. Update this source, or transform its created Futures to be compatible.\n See: https://github.com/fluture-js/Fluture#casting-futures"},invalidFuture=function(it,at,m,s){void 0===s&&(s="");var id=type.parse(type(m)),info="Future"===id.name?"\n"+("fluture"!==id.namespace?invalidNamespace(0,id.namespace):2!==id.version?invalidVersion(0,id.version):"Nothing seems wrong. Contact the Fluture maintainers."):"";typeError(it+" expects "+(ordinal[at]?"its "+ordinal[at]+" argument to be a valid Future":at)+"."+info+"\n Actual: "+show(m)+" :: "+id.name+s)},throwRejection=function(x){return error("Future#value was called on a rejected Future\n Actual: Future.reject("+show(x)+")")};Future$1.prototype.ap=function(other){return isFuture(this)||invalidContext("Future#ap",this),isFuture(other)||invalidFuture("Future#ap",0,other),this._ap(other)},Future$1.prototype.map=function(mapper){return isFuture(this)||invalidContext("Future#map",this),isFunction(mapper)||invalidArgument("Future#map",0,"to be a Function",mapper),this._map(mapper)},Future$1.prototype.bimap=function(lmapper,rmapper){return isFuture(this)||invalidContext("Future#bimap",this),isFunction(lmapper)||invalidArgument("Future#bimap",0,"to be a Function",lmapper),isFunction(rmapper)||invalidArgument("Future#bimap",1,"to be a Function",rmapper),this._bimap(lmapper,rmapper)},Future$1.prototype.chain=function(mapper){return isFuture(this)||invalidContext("Future#chain",this),isFunction(mapper)||invalidArgument("Future#chain",0,"to be a Function",mapper),this._chain(mapper)},Future$1.prototype.mapRej=function(mapper){return isFuture(this)||invalidContext("Future#mapRej",this),isFunction(mapper)||invalidArgument("Future#mapRej",0,"to be a Function",mapper),this._mapRej(mapper)},Future$1.prototype.chainRej=function(mapper){return isFuture(this)||invalidContext("Future#chainRej",this),isFunction(mapper)||invalidArgument("Future#chainRej",0,"to be a Function",mapper),this._chainRej(mapper)},Future$1.prototype.race=function(other){return isFuture(this)||invalidContext("Future#race",this),isFuture(other)||invalidFuture("Future#race",0,other),this._race(other)},Future$1.prototype.both=function(other){return isFuture(this)||invalidContext("Future#both",this),isFuture(other)||invalidFuture("Future#both",0,other),this._both(other)},Future$1.prototype.and=function(other){return isFuture(this)||invalidContext("Future#and",this),isFuture(other)||invalidFuture("Future#and",0,other),this._and(other)},Future$1.prototype.or=function(other){return isFuture(this)||invalidContext("Future#or",this),isFuture(other)||invalidFuture("Future#or",0,other),this._or(other)},Future$1.prototype.swap=function(){return isFuture(this)||invalidContext("Future#ap",this),this._swap()},Future$1.prototype.fold=function(lmapper,rmapper){return isFuture(this)||invalidContext("Future#ap",this),isFunction(lmapper)||invalidArgument("Future#fold",0,"to be a Function",lmapper),isFunction(rmapper)||invalidArgument("Future#fold",1,"to be a Function",rmapper),this._fold(lmapper,rmapper)},Future$1.prototype.finally=function(other){return isFuture(this)||invalidContext("Future#finally",this),isFuture(other)||invalidFuture("Future#finally",0,other),this._finally(other)},Future$1.prototype.lastly=function(other){return isFuture(this)||invalidContext("Future#lastly",this),isFuture(other)||invalidFuture("Future#lastly",0,other),this._finally(other)},Future$1.prototype.fork=function(rej,res){return isFuture(this)||invalidContext("Future#fork",this),isFunction(rej)||invalidArgument("Future#fork",0,"to be a Function",rej),isFunction(res)||invalidArgument("Future#fork",0,"to be a Function",res),this._fork(rej,res)},Future$1.prototype.value=function(res){return isFuture(this)||invalidContext("Future#value",this),isFunction(res)||invalidArgument("Future#value",0,"to be a Function",res),this._fork(throwRejection,res)},Future$1.prototype.promise=function(){var this$1=this;return new Promise(function(res,rej){return this$1._fork(rej,res)})},Future$1.prototype.isRejected=function(){return!1},Future$1.prototype.isResolved=function(){return!1},Future$1.prototype.isSettled=function(){return this.isRejected()||this.isResolved()},Future$1.prototype.extractLeft=function(){return[]},Future$1.prototype.extractRight=function(){return[]};var Core=Object.create(Future$1.prototype);Core._ap=function(other){return new Sequence(this,[new ApAction(other)])},Core._map=function(mapper){return new Sequence(this,[new MapAction(mapper)])},Core._bimap=function(lmapper,rmapper){return new Sequence(this,[new BimapAction(lmapper,rmapper)])},Core._chain=function(mapper){return new Sequence(this,[new ChainAction(mapper)])},Core._mapRej=function(mapper){return new Sequence(this,[new MapRejAction(mapper)])},Core._chainRej=function(mapper){return new Sequence(this,[new ChainRejAction(mapper)])},Core._race=function(other){return new Sequence(this,[new RaceAction(other)])},Core._both=function(other){return new Sequence(this,[new BothAction(other)])},Core._and=function(other){return new Sequence(this,[new AndAction(other)])},Core._or=function(other){return new Sequence(this,[new OrAction(other)])},Core._swap=function(){return new Sequence(this,[new SwapAction])},Core._fold=function(lmapper,rmapper){return new Sequence(this,[new FoldAction(lmapper,rmapper)])},Core._finally=function(other){return new Sequence(this,[new FinallyAction(other)])},Computation.prototype=Object.create(Core),Computation.prototype._fork=function(rej,res){var open=!0,f=this._computation(function(x){open&&(open=!1,rej(x))},function(x){open&&(open=!1,res(x))});return check$fork(f,this._computation),function(){open&&f&&f(),open=!1}},Computation.prototype.toString=function(){return"Future("+showf(this._computation)+")"},Rejected.prototype=Object.create(Core),Rejected.prototype._ap=moop,Rejected.prototype._map=moop,Rejected.prototype._chain=moop,Rejected.prototype._race=moop,Rejected.prototype._both=moop,Rejected.prototype._and=moop,Rejected.prototype._or=function(other){return other},Rejected.prototype._finally=function(other){return other._and(this)},Rejected.prototype._swap=function(){return new Resolved(this._value)},Rejected.prototype._fork=function(rej){return rej(this._value),noop},Rejected.prototype.isRejected=function(){return!0},Rejected.prototype.extractLeft=function(){return[this._value]},Rejected.prototype.toString=function(){return"Future.reject("+show(this._value)+")"};var reject=function(x){return new Rejected(x)};Resolved.prototype=Object.create(Core),Resolved.prototype._race=moop,Resolved.prototype._mapRej=moop,Resolved.prototype._or=moop,Resolved.prototype._and=function(other){return other},Resolved.prototype._both=function(other){var this$1=this;return other._map(function(x){return[this$1._value,x]})},Resolved.prototype._swap=function(){return new Rejected(this._value)},Resolved.prototype._finally=function(other){var this$1=this;return other._map(function(){return this$1._value})},Resolved.prototype._fork=function(rej,res){return res(this._value),noop},Resolved.prototype.isResolved=function(){return!0},Resolved.prototype.extractRight=function(){return[this._value]},Resolved.prototype.toString=function(){return"Future.of("+show(this._value)+")"};var of=function(x){return new Resolved(x)};Never.prototype=Object.create(Future$1.prototype),Never.prototype._ap=moop,Never.prototype._map=moop,Never.prototype._bimap=moop,Never.prototype._chain=moop,Never.prototype._mapRej=moop,Never.prototype._chainRej=moop,Never.prototype._both=moop,Never.prototype._or=moop,Never.prototype._swap=moop,Never.prototype._fold=moop,Never.prototype._finally=moop,Never.prototype._race=function(other){return other},Never.prototype._fork=function(){return noop},Never.prototype.toString=function(){return"Future.never"};var never=new Never,isNever=function(x){return x===never};Eager.prototype=Object.create(Core),Eager.prototype._fork=function(rej,res){return this.rejected?rej(this.value):this.resolved?res(this.value):(this.rej=rej,this.res=res),this.cancel};var Action=function(){};Action.prototype.rejected=function(x){return new Rejected(x)},Action.prototype.resolved=function(x){return new Resolved(x)},Action.prototype.run=function(){return this},Action.prototype.cancel=function(){};var check$ap=function(f){return isFunction(f)?f:typeError("Future#ap expects its first argument to be a Future of a Function\n Actual: Future.of("+show(f)+")")},ApAction=function(Action){function ApAction(other){Action.call(this),this.other=other}return Action&&(ApAction.__proto__=Action),ApAction.prototype=Object.create(Action&&Action.prototype),ApAction.prototype.constructor=ApAction,ApAction.prototype.resolved=function(f){return check$ap(f),this.other._map(function(x){return f(x)})},ApAction.prototype.toString=function(){return"ap("+this.other.toString()+")"},ApAction}(Action),MapAction=function(Action){function MapAction(mapper){Action.call(this),this.mapper=mapper}return Action&&(MapAction.__proto__=Action),MapAction.prototype=Object.create(Action&&Action.prototype),MapAction.prototype.constructor=MapAction,MapAction.prototype.resolved=function(x){return new Resolved(this.mapper(x))},MapAction.prototype.toString=function(){return"map("+showf(this.mapper)+")"},MapAction}(Action),BimapAction=function(Action){function BimapAction(lmapper,rmapper){Action.call(this),this.lmapper=lmapper,this.rmapper=rmapper}return Action&&(BimapAction.__proto__=Action),BimapAction.prototype=Object.create(Action&&Action.prototype),BimapAction.prototype.constructor=BimapAction,BimapAction.prototype.rejected=function(x){return new Rejected(this.lmapper(x))},BimapAction.prototype.resolved=function(x){return new Resolved(this.rmapper(x))},BimapAction.prototype.toString=function(){return"bimap("+showf(this.lmapper)+", "+showf(this.rmapper)+")"},BimapAction}(Action),check$chain=function(m,f,x){return isFuture(m)?m:invalidFuture("Future#chain","the function it's given to return a Future",m,"\n From calling: "+showf(f)+"\n With: "+show(x))},ChainAction=function(Action){function ChainAction(mapper){Action.call(this),this.mapper=mapper}return Action&&(ChainAction.__proto__=Action),ChainAction.prototype=Object.create(Action&&Action.prototype),ChainAction.prototype.constructor=ChainAction,ChainAction.prototype.resolved=function(x){return check$chain(this.mapper(x),this.mapper,x)},ChainAction.prototype.toString=function(){return"chain("+showf(this.mapper)+")"},ChainAction}(Action),MapRejAction=function(Action){function MapRejAction(mapper){Action.call(this),this.mapper=mapper}return Action&&(MapRejAction.__proto__=Action),MapRejAction.prototype=Object.create(Action&&Action.prototype),MapRejAction.prototype.constructor=MapRejAction,MapRejAction.prototype.rejected=function(x){return new Rejected(this.mapper(x))},MapRejAction.prototype.toString=function(){return"mapRej("+showf(this.mapper)+")"},MapRejAction}(Action),check$chainRej=function(m,f,x){return isFuture(m)?m:invalidFuture("Future#chainRej","the function it's given to return a Future",m,"\n From calling: "+showf(f)+"\n With: "+show(x))},ChainRejAction=function(Action){function ChainRejAction(mapper){Action.call(this),this.mapper=mapper}return Action&&(ChainRejAction.__proto__=Action),ChainRejAction.prototype=Object.create(Action&&Action.prototype),ChainRejAction.prototype.constructor=ChainRejAction,ChainRejAction.prototype.rejected=function(x){return check$chainRej(this.mapper(x),this.mapper,x)},ChainRejAction.prototype.toString=function(){return"chainRej("+showf(this.mapper)+")"},ChainRejAction}(Action),SwapAction=function(Action){function SwapAction(){return Action.call(this),SwapAction.instance||(SwapAction.instance=this)}return Action&&(SwapAction.__proto__=Action),SwapAction.prototype=Object.create(Action&&Action.prototype),SwapAction.prototype.constructor=SwapAction,SwapAction.prototype.rejected=function(x){return new Resolved(x)},SwapAction.prototype.resolved=function(x){return new Rejected(x)},SwapAction.prototype.toString=function(){return"swap()"},SwapAction}(Action),FoldAction=function(Action){function FoldAction(lmapper,rmapper){Action.call(this),this.lmapper=lmapper,this.rmapper=rmapper}return Action&&(FoldAction.__proto__=Action),FoldAction.prototype=Object.create(Action&&Action.prototype),FoldAction.prototype.constructor=FoldAction,FoldAction.prototype.rejected=function(x){return new Resolved(this.lmapper(x))},FoldAction.prototype.resolved=function(x){return new Resolved(this.rmapper(x))},FoldAction.prototype.toString=function(){return"fold("+showf(this.lmapper)+", "+showf(this.rmapper)+")"},FoldAction}(Action),FinallyAction=function(Action){function FinallyAction(other){Action.call(this),this.other=other}return Action&&(FinallyAction.__proto__=Action),FinallyAction.prototype=Object.create(Action&&Action.prototype),FinallyAction.prototype.constructor=FinallyAction,FinallyAction.prototype.cancel=function(){this.other._fork(noop,noop)()},FinallyAction.prototype.rejected=function(x){return this.other._and(new Rejected(x))},FinallyAction.prototype.resolved=function(x){return this.other._map(function(){return x})},FinallyAction.prototype.toString=function(){return"finally("+this.other.toString()+")"},FinallyAction}(Action),AndAction=function(Action){function AndAction(other){Action.call(this),this.other=other}return Action&&(AndAction.__proto__=Action),AndAction.prototype=Object.create(Action&&Action.prototype),AndAction.prototype.constructor=AndAction,AndAction.prototype.resolved=function(){return this.other},AndAction.prototype.toString=function(){return"and("+this.other.toString()+")"},AndAction}(Action),OrAction=function(Action){function OrAction(other){Action.call(this),this.other=other}return Action&&(OrAction.__proto__=Action),OrAction.prototype=Object.create(Action&&Action.prototype),OrAction.prototype.constructor=OrAction,OrAction.prototype.rejected=function(){return this.other},OrAction.prototype.toString=function(){return"or("+this.other.toString()+")"},OrAction}(Action),RaceAction=function(Action){function RaceAction(other){Action.call(this),this.other=other}return Action&&(RaceAction.__proto__=Action),RaceAction.prototype=Object.create(Action&&Action.prototype),RaceAction.prototype.constructor=RaceAction,RaceAction.prototype.run=function(early){return new RaceActionState(early,this.other)},RaceAction.prototype.toString=function(){return"race("+this.other.toString()+")"},RaceAction}(Action),RaceActionState=function(RaceAction){function RaceActionState(early,other){var this$1=this;RaceAction.call(this,other),this.cancel=other._fork(function(x){return early(new Rejected(x),this$1)},function(x){return early(new Resolved(x),this$1)})}return RaceAction&&(RaceActionState.__proto__=RaceAction),RaceActionState.prototype=Object.create(RaceAction&&RaceAction.prototype),RaceActionState.prototype.constructor=RaceActionState,RaceActionState.prototype.rejected=function(x){return this.cancel(),new Rejected(x)},RaceActionState.prototype.resolved=function(x){return this.cancel(),new Resolved(x)},RaceActionState}(RaceAction),BothAction=function(Action){function BothAction(other){Action.call(this),this.other=other}return Action&&(BothAction.__proto__=Action),BothAction.prototype=Object.create(Action&&Action.prototype),BothAction.prototype.constructor=BothAction,BothAction.prototype.run=function(early){return new BothActionState(early,this.other)},BothAction.prototype.resolved=function(x){return this.other._map(function(y){return[x,y]})},BothAction.prototype.toString=function(){return"both("+this.other.toString()+")"},BothAction}(Action),BothActionState=function(BothAction){function BothActionState(early,other){var this$1=this;BothAction.call(this,new Eager(other)),this.cancel=this.other.fork(function(x){return early(new Rejected(x),this$1)},noop)}return BothAction&&(BothActionState.__proto__=BothAction),BothActionState.prototype=Object.create(BothAction&&BothAction.prototype),BothActionState.prototype.constructor=BothActionState,BothActionState}(BothAction);Sequence.prototype=Object.create(Future$1.prototype),Sequence.prototype._transform=function(action){return new Sequence(this._spawn,this._actions.concat([action]))},Sequence.prototype._ap=function(other){return this._transform(new ApAction(other))},Sequence.prototype._map=function(mapper){return this._transform(new MapAction(mapper))},Sequence.prototype._bimap=function(lmapper,rmapper){return this._transform(new BimapAction(lmapper,rmapper))},Sequence.prototype._chain=function(mapper){return this._transform(new ChainAction(mapper))},Sequence.prototype._mapRej=function(mapper){return this._transform(new MapRejAction(mapper))},Sequence.prototype._chainRej=function(mapper){return this._transform(new ChainRejAction(mapper))},Sequence.prototype._race=function(other){return isNever(other)?this:this._transform(new RaceAction(other))},Sequence.prototype._both=function(other){return this._transform(new BothAction(other))},Sequence.prototype._and=function(other){return this._transform(new AndAction(other))},Sequence.prototype._or=function(other){return this._transform(new OrAction(other))},Sequence.prototype._swap=function(){return this._transform(new SwapAction)},Sequence.prototype._fold=function(lmapper,rmapper){return this._transform(new FoldAction(lmapper,rmapper))},Sequence.prototype._finally=function(other){return this._transform(new FinallyAction(other))},Sequence.prototype._fork=function(rej,res){function settle(m){if(settled=!0,(future=m)instanceof Sequence){for(var i=future._actions.length-1;i>=0;i--)stack.unshift(future._actions[i]);future=future._spawn}}function early(m,terminator){if(cancel(),action!==terminator)for(action.cancel();(it=queue.shift())&&it!==terminator;)it.cancel();settle(m),async&&drain()}function rejected(x){settle(action.rejected(x)),async&&drain()}function resolved(x){settle(action.resolved(x)),async&&drain()}function drain(){for(async=!1;action=stack.shift()||queue.shift();)if(settled=!1,cancel=future._fork(rejected,resolved),!settled&&(action=action.run(early),!settled)){for(;it=stack.shift();){var tmp=it.run(early);if(settled)break;queue.push(tmp)}if(!settled)return void(async=!0)}cancel=future._fork(rej,res)}var action,it,settled,async,stack=new Denque(this._actions),queue=new Denque(this._actions.length),cancel=noop,future=this._spawn;return drain(),function(){for(cancel(),action&&action.cancel();it=queue.shift();)it.cancel();stack.clear(),cancel=noop}},Sequence.prototype.toString=function(){return""+this._spawn.toString()+this._actions.map(function(x){return"."+x.toString()}).join("")};var Next=function(x){return{done:!1,value:x}},Done=function(x){return{done:!0,value:x}},isIteration=function(x){return isObject(x)&&isBoolean(x.done)},Undetermined=0,Synchronous=1,Asynchronous=2;ChainRec.prototype=Object.create(Core),ChainRec.prototype._fork=function(rej,res){function resolved(it){state=it,timing=timing===Undetermined?Synchronous:drain()}function drain(){for(;!state.done;){timing=Undetermined;var m=_step(Next,Done,state.value);if(cancel=m._fork(rej,resolved),timing!==Synchronous)return void(timing=Asynchronous)}res(state.value)}var ref=this,_step=ref._step,_init=ref._init,timing=Undetermined,cancel=noop,state=Next(_init);return drain(),function(){cancel()}},ChainRec.prototype.toString=function(){return"Future.chainRec("+showf(this._step)+", "+show(this._init)+")"};var dispatchers=Object.freeze({ap:ap,map:map,bimap:bimap,chain:chain,mapRej:mapRej,chainRej:chainRej,lastly:lastly,finally:lastly,and:and,both:both,or:or,race:race,swap:swap,fold:fold,fork:fork,promise:promise,value:value,extractLeft:extractLeft,extractRight:extractRight});Future$1["@@type"]=$$type,Future$1[FL.of]=Future$1.of=of,Future$1[FL.chainRec]=Future$1.chainRec=chainRec,Future$1.reject=reject,Future$1.ap=ap,Future$1.prototype[FL.ap]=function(other){return other._ap(this)},Future$1.map=map,Future$1.prototype[FL.map]=function(mapper){return this._map(mapper)},Future$1.bimap=bimap,Future$1.prototype[FL.bimap]=function(lmapper,rmapper){return this._bimap(lmapper,rmapper)},Future$1.chain=chain,Future$1.prototype[FL.chain]=function(mapper){return this._chain(mapper)},After.prototype=Object.create(Core),After.prototype._race=After$race,After.prototype._swap=function(){return new RejectAfter(this._time,this._value)},After.prototype._fork=function(rej,res){var id=setTimeout(res,this._time,this._value);return function(){clearTimeout(id)}},After.prototype.extractRight=function(){return[this._value]},After.prototype.toString=function(){return"Future.after("+show(this._time)+", "+show(this._value)+")"},RejectAfter.prototype=Object.create(Core),RejectAfter.prototype._race=After$race,RejectAfter.prototype._swap=function(){return new After(this._time,this._value)},RejectAfter.prototype._fork=function(rej){var id=setTimeout(rej,this._time,this._value);return function(){clearTimeout(id)}},RejectAfter.prototype.extractLeft=function(){return[this._value]},RejectAfter.prototype.toString=function(){return"Future.rejectAfter("+show(this._time)+", "+show(this._value)+")"},Attempt.prototype=Object.create(Core),Attempt.prototype._fork=function(rej,res){var r;try{r=this._fn()}catch(e){return rej(e),noop}return res(r),noop},Attempt.prototype.toString=function(){return"Future.try("+showf(this._fn)+")"};var Cold=Cached.Cold=0,Pending=Cached.Pending=1,Rejected$1=Cached.Rejected=2,Resolved$1=Cached.Resolved=3;Cached.prototype=Object.create(Core),Cached.prototype.isRejected=function(){return this._state===Rejected$1},Cached.prototype.isResolved=function(){return this._state===Resolved$1},Cached.prototype.extractLeft=function(){return this.isRejected()?[this._value]:[]},Cached.prototype.extractRight=function(){return this.isResolved()?[this._value]:[]},Cached.prototype._addToQueue=function(rej,res){var _this=this;if(_this._state>Pending)return noop;var i=_this._queue.push(new Queued(rej,res))-1;return _this._queued=_this._queued+1,function(){_this._state>Pending||(_this._queue[i]=void 0,_this._queued=_this._queued-1,0===_this._queued&&_this.reset())}},Cached.prototype._drainQueue=function(){if(!(this._state<=Pending)&&0!==this._queued){for(var queue=this._queue,length=queue.length,state=this._state,value=this._value,i=0;i<length;i++)queue[i]&&queue[i][state](value),queue[i]=void 0;this._queue=void 0,this._queued=0}},Cached.prototype.reject=function(reason){this._state>Pending||(this._value=reason,this._state=Rejected$1,this._drainQueue())},Cached.prototype.resolve=function(value){this._state>Pending||(this._value=value,this._state=Resolved$1,this._drainQueue())},Cached.prototype.run=function(){var _this=this;_this._state>Cold||(_this._state=Pending,_this._cancel=_this._pure._fork(function(x){_this.reject(x)},function(x){_this.resolve(x)}))},Cached.prototype.reset=function(){this._state!==Cold&&(this._state>Pending&&this._cancel(),this._cancel=noop,this._queue=[],this._queued=0,this._value=void 0,this._state=Cold)},Cached.prototype._fork=function(rej,res){var cancel=noop;switch(this._state){case Pending:cancel=this._addToQueue(rej,res);break;case Rejected$1:rej(this._value);break;case Resolved$1:res(this._value);break;default:cancel=this._addToQueue(rej,res),this.run()}return cancel},Cached.prototype.toString=function(){return"Future.cache("+this._pure.toString()+")"},Encase.prototype=Object.create(Core),Encase.prototype._fork=function(rej,res){var r;try{r=this._fn(this._a)}catch(e){return rej(e),noop}return res(r),noop},Encase.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a;return"Future.encase("+showf(_fn)+", "+show(_a)+")"},Encase2.prototype=Object.create(Core),Encase2.prototype._fork=function(rej,res){var r;try{r=this._fn(this._a,this._b)}catch(e){return rej(e),noop}return res(r),noop},Encase2.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b;return"Future.encase2("+showf(_fn)+", "+show(_a)+", "+show(_b)+")"},Encase3.prototype=Object.create(Core),Encase3.prototype._fork=function(rej,res){var r;try{r=this._fn(this._a,this._b,this._c)}catch(e){return rej(e),noop}return res(r),noop},Encase3.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b,_c=ref._c;return"Future.encase3("+showf(_fn)+", "+show(_a)+", "+show(_b)+", "+show(_c)+")"},EncaseN.prototype=Object.create(Core),EncaseN.prototype._fork=function(rej,res){var open=!0;return this._fn(this._a,function(err,val){open&&(open=!1,err?rej(err):res(val))}),function(){open=!1}},EncaseN.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a;return"Future.encaseN("+showf(_fn)+", "+show(_a)+")"},EncaseN2.prototype=Object.create(Core),EncaseN2.prototype._fork=function(rej,res){var open=!0;return this._fn(this._a,this._b,function(err,val){open&&(open=!1,err?rej(err):res(val))}),function(){open=!1}},EncaseN2.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b;return"Future.encaseN2("+showf(_fn)+", "+show(_a)+", "+show(_b)+")"},EncaseN$1.prototype=Object.create(Core),EncaseN$1.prototype._fork=function(rej,res){var open=!0;return this._fn(this._a,this._b,this._c,function(err,val){open&&(open=!1,err?rej(err):res(val))}),function(){open=!1}},EncaseN$1.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b,_c=ref._c;return"Future.encaseN3("+showf(_fn)+", "+show(_a)+", "+show(_b)+", "+show(_c)+")"},EncaseP.prototype=Object.create(Core),EncaseP.prototype._fork=function(rej,res){var ref=this,_fn=ref._fn,_a=ref._a;return check$promise(_fn(_a),_fn,_a).then(escapeTick(res),escapeTick(rej)),noop},EncaseP.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a;return"Future.encaseP("+showf(_fn)+", "+show(_a)+")"},EncaseP2.prototype=Object.create(Core),EncaseP2.prototype._fork=function(rej,res){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b;return check$promise$1(_fn(_a,_b),_fn,_a,_b).then(escapeTick(res),escapeTick(rej)),noop},EncaseP2.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b;return"Future.encaseP2("+showf(_fn)+", "+show(_a)+", "+show(_b)+")"},EncaseP3.prototype=Object.create(Core),EncaseP3.prototype._fork=function(rej,res){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b,_c=ref._c;return check$promise$2(_fn(_a,_b,_c),_fn,_a,_b,_c).then(escapeTick(res),escapeTick(rej)),noop},EncaseP3.prototype.toString=function(){var ref=this,_fn=ref._fn,_a=ref._a,_b=ref._b,_c=ref._c;return"Future.encaseP3("+show(_fn)+", "+show(_a)+", "+show(_b)+", "+show(_c)+")"};var check$iterator=function(g){return isIterator(g)?g:invalidArgument("Future.do",0,'return an iterator, maybe you forgot the "*"',g)},check$iteration=function(o){return isIteration(o)||typeError("Future.do was given an invalid generator: Its iterator did not return a valid iteration from iterator.next()\n Actual: "+show(o)),o.done||isFuture(o.value)?o:invalidFuture("Future.do","the iterator to produce only valid Futures",o.value,"\n Tip: If you're using a generator, make sure you always yield a Future")};Go.prototype=Object.create(Core),Go.prototype._fork=function(rej,res){function resolved(x){if(value=x,timing===Asynchronous)return drain();timing=Synchronous,state=check$iteration(iterator.next(value))}function drain(){for(state=check$iteration(iterator.next(value));!state.done;)if(timing=Undetermined,cancel=state.value._fork(rej,resolved),timing!==Synchronous)return void(timing=Asynchronous);res(state.value)}var state,value,iterator=check$iterator(this._generator()),timing=Undetermined,cancel=noop;return drain(),function(){cancel()}},Go.prototype.toString=function(){return"Future.do("+showf(this._generator)+")"},Hook.prototype=Object.create(Core),Hook.prototype._fork=function(rej,res){function Hook$done(){cont(value)}function Hook$dispose(){var disposal=_dispose(resource);return check$dispose(disposal,_dispose,resource),cancel=disposal._fork(rej,Hook$done)}function Hook$cancelConsuption(){cancelConsume(),Hook$dispose()()}function Hook$consumptionRejected(x){cont=rej,value=x,Hook$dispose()}function Hook$consumptionResolved(x){cont=res,value=x,Hook$dispose()}function Hook$acquireResolved(x){var consumption=_consume(resource=x);check$consume(consumption,_consume,resource),cancel=Hook$cancelConsuption,cancelConsume=consumption._fork(Hook$consumptionRejected,Hook$consumptionResolved)}var cancel,resource,value,ref=this,_acquire=ref._acquire,_dispose=ref._dispose,_consume=ref._consume,cancelAcquire=noop,cancelConsume=noop,cont=noop;return cancelAcquire=_acquire._fork(rej,Hook$acquireResolved),cancel=cancel||cancelAcquire,function(){cancel()}},Hook.prototype.toString=function(){var ref=this,_acquire=ref._acquire,_dispose=ref._dispose,_consume=ref._consume;return"Future.hook("+_acquire.toString()+", "+showf(_dispose)+", "+showf(_consume)+")"},Node.prototype=Object.create(Core),Node.prototype._fork=function(rej,res){var open=!0;return this._fn(function(err,val){open&&(open=!1,err?rej(err):res(val))}),function(){open=!1}},Node.prototype.toString=function(){var _fn=this._fn;return"Future.node("+showf(_fn)+")"},ParallelAp.prototype=Object.create(Core),ParallelAp.prototype._fork=function(rej,res){function ParallelAp$rej(x){rejected||(rejected=!0,rej(x))}var func,val,c1,c2,okval=!1,okfunc=!1,rejected=!1;return c1=this._mval._fork(ParallelAp$rej,function(x){if(c1=noop,!okval)return okfunc=!0,void(val=x);res(func(x))}),c2=this._mfunc._fork(ParallelAp$rej,function(f){if(c2=noop,check$ap$f(f),!okfunc)return okval=!0,void(func=f);res(f(val))}),function(){c1(),c2()}},ParallelAp.prototype.toString=function(){return"new ParallelAp("+this._mval.toString()+", "+this._mfunc.toString()+")"};var Par=concurrify(Future$1,never,race,function(mval,mfunc){return new ParallelAp(mval,mfunc)}),check$parallel=function(m,i){return isFuture(m)?m:invalidFuture("Future.parallel","its second argument to be an array of valid Futures. The value at position "+i+" in the array is not a Future",m)};Parallel.prototype=Object.create(Core),Parallel.prototype._fork=function(rej,res){function Parallel$fork$cancelAll(){for(var n=0;n<_max;n++)cancels[n]&&cancels[n]()}function Parallel$fork$rej(reason){Parallel$fork$cancelAll(),rej(reason)}function Parallel$fork$run(future,idx,cancelSlot){cancels[cancelSlot]=future._fork(Parallel$fork$rej,function(value){out[idx]=value,i<_length?Parallel$fork$run(_futures[i],i++,cancelSlot):++i-_max===_length&&res(out)})}for(var ref=this,_futures=ref._futures,_length=ref._length,_max=ref._max,cancels=new Array(_max),out=new Array(_length),i=_max,n=0;n<_max;n++)Parallel$fork$run(_futures[n],n,n);return Parallel$fork$cancelAll},Parallel.prototype.toString=function(){return"Future.parallel("+this._max+", "+show(this._futures)+")"};var emptyArray=new Resolved([]);return TryP.prototype=Object.create(Core),TryP.prototype._fork=function(rej,res){var _fn=this._fn;return check$promise$3(_fn(),_fn).then(escapeTick(res),escapeTick(rej)),noop},TryP.prototype.toString=function(){var _fn=this._fn;return"Future.tryP("+show(_fn)+")"},"function"!=typeof Object.create&&error("Please polyfill Object.create to use Fluture"),"function"!=typeof Object.assign&&error("Please polyfill Object.assign to use Fluture"),"function"!=typeof Array.isArray&&error("Please polyfill Array.isArray to use Fluture"),Object.assign(Future$1,dispatchers,{Future:Future$1,after:after,attempt:attempt,cache:cache,chainRec:chainRec,do:go,encase:encase,encase2:encase2,encase3:encase3,encaseN:encaseN,encaseN2:encaseN2,encaseN3:encaseN3,encaseP:encaseP,encaseP2:encaseP2,encaseP3:encaseP3,go:go,hook:hook,isFuture:isFuture,isNever:isNever,never:never,node:node,of:of,Par:Par,parallel:parallel,reject:reject,rejectAfter:rejectAfter,seq:seq,try:attempt,tryP:tryP})});
{
"name": "fluture",
"version": "6.1.0",
"version": "6.1.1",
"description": "FantasyLand compliant (monadic) alternative to Promises",

@@ -59,3 +59,3 @@ "main": "index.js",

"inspect-f": "^1.2.0",
"sanctuary-type-classes": "^5.1.0",
"sanctuary-type-classes": "^6.0.0",
"sanctuary-type-identifiers": "^2.0.0"

@@ -65,3 +65,3 @@ },

"benchmark": "^2.1.0",
"chai": "^3.4.0",
"chai": "^4.0.0",
"codecov": "^2.2.0",

@@ -79,3 +79,3 @@ "data.task": "^3.0.0",

"mocha": "^3.4.1",
"ramda": "^0.23.0",
"ramda": "^0.24.0",
"ramda-fantasy": "^0.8.0",

@@ -89,3 +89,3 @@ "remark-cli": "^3.0.1",

"rollup-plugin-multi-entry": "^2.0.1",
"rollup-plugin-uglify": "^1.0.1",
"rollup-plugin-uglify": "^2.0.1",
"source-map-support": "^0.4.14",

@@ -92,0 +92,0 @@ "xyz": "^2.0.1"

@@ -98,2 +98,3 @@ # [![Fluture](logo.png)](#butterfly)

* [encaseN](#encasen)
* [chainRec](#chainrec)
1. [Transforming Futures](#transforming-futures)

@@ -478,2 +479,9 @@ * [map](#map)

#### chainRec
##### `.chainRec :: ((a -> c, b -> c, a) -> Future e c, a) -> Future e b`
Implementation of [Fantasy Land ChainRec][FL:chainrec]. Since Fluture 6.0
introduced [stack safety](#stack-safety) there should be no need to use this
function directly. Instead it's recommended to use [`chain(rec)`](#chain).
### Transforming Futures

@@ -1016,13 +1024,6 @@

const {create, env} = require('sanctuary');
const {Unknown} = require('sanctuary-def');
const {FutureType, ConcurrentFutureType} = require('fluture-sanctuary-types');
const {env: flutureEnv} = require('fluture-sanctuary-types');
const Future = require('fluture');
const S = create({
checkTypes: true,
env: env.concat([
FutureType(Unknown, Unknown),
ConcurrentFutureType(Unknown, Unknown)
])
});
const S = create({checkTypes: true, env: env.concat(flutureEnv)});

@@ -1077,2 +1078,3 @@ S.I(Future.of(1));

[FL:bifunctor]: https://github.com/fantasyland/fantasy-land#bifunctor
[FL:chainrec]: https://github.com/fantasyland/fantasy-land#chainrec

@@ -1079,0 +1081,0 @@ [JS:Object.create]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign

@@ -1,6 +0,5 @@

import {Future, Core} from './core';
import {Core} from './core';
import {Next, Done} from './internal/iteration';
import {Undetermined, Synchronous, Asynchronous} from './internal/timing';
import {show, showf, noop} from './internal/fn';
import {FL} from './internal/const';

@@ -50,3 +49,1 @@ export function ChainRec(step, init){

}
Future[FL.chainRec] = chainRec;

@@ -8,3 +8,3 @@ /*eslint no-param-reassign:0, no-cond-assign:0, no-unmodified-loop-condition:0 */

import {error, typeError, invalidArgument, invalidContext, invalidFuture} from './internal/throw';
import {FL, $$type} from './internal/const';
import {$$type} from './internal/const';
import type from 'sanctuary-type-identifiers';

@@ -25,18 +25,2 @@

Future.prototype[FL.ap] = function Future$FL$ap(other){
return other._ap(this);
};
Future.prototype[FL.map] = function Future$FL$map(mapper){
return this._map(mapper);
};
Future.prototype[FL.bimap] = function Future$FL$bimap(lmapper, rmapper){
return this._bimap(lmapper, rmapper);
};
Future.prototype[FL.chain] = function Future$FL$chain(mapper){
return this._chain(mapper);
};
Future.prototype.ap = function Future$ap(other){

@@ -434,3 +418,3 @@ if(!isFuture(this)) invalidContext('Future#ap', this);

'Future#chain',
'the function its given to return a Future',
'the function it\'s given to return a Future',
m,

@@ -451,3 +435,3 @@ `\n From calling: ${showf(f)}\n With: ${show(x)}`

'Future#chainRej',
'the function its given to return a Future',
'the function it\'s given to return a Future',
m,

@@ -648,4 +632,1 @@ `\n From calling: ${showf(f)}\n With: ${show(x)}`

};
Future['@@type'] = $$type;
Future[FL.of] = of;

@@ -8,3 +8,3 @@ import {Core} from './core';

return isThenable(p) ? p : typeError(
'Future.encaseP expects the function its given to return a Promise/Thenable'
'Future.encaseP expects the function it\'s given to return a Promise/Thenable'
+ `\n Actual: ${show(p)}\n From calling: ${showf(f)}`

@@ -11,0 +11,0 @@ + `\n With: ${show(a)}`

@@ -8,3 +8,3 @@ import {Core} from './core';

return isThenable(p) ? p : typeError(
'Future.encaseP2 expects the function its given to return a Promise/Thenable'
'Future.encaseP2 expects the function it\'s given to return a Promise/Thenable'
+ `\n Actual: ${show(p)}\n From calling: ${showf(f)}`

@@ -11,0 +11,0 @@ + `\n With 1: ${show(a)}`

@@ -8,3 +8,3 @@ import {Core} from './core';

return isThenable(p) ? p : typeError(
'Future.encaseP3 expects the function its given to return a Promise/Thenable'
'Future.encaseP3 expects the function it\'s given to return a Promise/Thenable'
+ `\n Actual: ${show(p)}\n From calling: ${showf(f)}`

@@ -11,0 +11,0 @@ + `\n With 1: ${show(a)}`

@@ -9,3 +9,3 @@ import {Core, isFuture} from './core';

'Future.hook',
'the first function its given to return a Future',
'the first function it\'s given to return a Future',
m,

@@ -19,3 +19,3 @@ `\n From calling: ${showf(f)}\n With: ${show(x)}`

'Future.hook',
'the second function its given to return a Future',
'the second function it\'s given to return a Future',
m,

@@ -22,0 +22,0 @@ `\n From calling: ${showf(f)}\n With: ${show(x)}`

@@ -1,9 +0,3 @@

import {
Future,
isFuture,
isNever,
never,
of,
reject
} from './core';
import Future from './future';
import {isFuture, isNever, never, of, reject} from './core';

@@ -10,0 +4,0 @@ import * as dispatchers from './dispatchers';

@@ -8,3 +8,3 @@ import {Core} from './core';

return isThenable(p) ? p : typeError(
'Future.tryP expects the function its given to return a Promise/Thenable'
'Future.tryP expects the function it\'s given to return a Promise/Thenable'
+ `\n Actual: ${show(p)}\n From calling: ${showf(f)}`

@@ -11,0 +11,0 @@ );

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc