Comparing version 0.7.27 to 0.7.28
@@ -1,2 +0,2 @@ | ||
(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,ab,bb,cb,db,eb,fb,gb,hb=[].slice,ib={}.hasOwnProperty,jb=function(a,b){function c(){this.constructor=a}for(var d in b)ib.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},kb=function(a,b){return function(){return a.apply(b,arguments)}};a={toString:function(){return"Bacon"}},a.version="0.7.27",l=("undefined"!=typeof global&&null!==global?global:this).Error,a.fromBinder=function(b,c){return null==c&&(c=fb.id),new k(A(a,"fromBinder",b,c),function(d){var e,f,g;return g=!1,e=function(){return"undefined"!=typeof f&&null!==f?(g||f(),g=!0):void 0},f=b(function(){var b,g,h,i,k,l;for(b=1<=arguments.length?hb.call(arguments,0):[],i=c.apply(this,b),I(i)&&fb.last(i)instanceof j||(i=[i]),h=a.more,k=0,l=i.length;l>k;k++)if(g=i[k],h=d(g=$(g)),h===a.noMore||g.isEnd())return null!=f?e():a.scheduler.setTimeout(e,0),h;return h}),e})},a.$={},a.$.asEventStream=function(b,c,d){var e;return K(c)&&(e=[c,void 0],d=e[0],c=e[1]),db(this.selector||this,"asEventStream",b,a.fromBinder(function(a){return function(d){return a.on(b,c,d),function(){return a.off(b,c,d)}}}(this),d))},null!=(gb="undefined"!=typeof jQuery&&null!==jQuery?jQuery:"undefined"!=typeof Zepto&&null!==Zepto?Zepto:void 0)&&(gb.fn.asEventStream=a.$.asEventStream),a.fromEventTarget=function(b,c,d){var e,f,g,h,i,j;return e=null!=(g=b.addEventListener)?g:null!=(h=b.addListener)?h:b.bind,f=null!=(i=b.removeEventListener)?i:null!=(j=b.removeListener)?j:b.unbind,db(a,"fromEventTarget",b,c,a.fromBinder(function(a){return e.call(b,c,a),function(){return f.call(b,c,a)}},d))},a.fromPromise=function(b,c){return db(a,"fromPromise",b,a.fromBinder(function(a){return b.then(a,function(b){return a(new i(b))}),function(){return c&&"function"==typeof b.abort?b.abort():void 0}},function(a){return[a,B()]}))},a.noMore=["<no-more>"],a.more=["<more>"],a.later=function(b,c){return db(a,"later",b,c,a.sequentially(b,[c]))},a.sequentially=function(b,c){var d;return d=0,db(a,"sequentially",b,c,a.fromPoll(b,function(){var a;return a=c[d++],d<c.length?a:d===c.length?[a,B()]:B()}))},a.repeatedly=function(b,c){var d;return d=0,db(a,"repeatedly",b,c,a.fromPoll(b,function(){return c[d++%c.length]}))},a.spy=function(a){return Y.push(a)},Y=[],X=function(a){var b,c,d;if(Y.length&&!X.running)try{for(X.running=!0,c=0,d=Y.length;d>c;c++)(b=Y[c])(a)}finally{delete X.running}return void 0},eb=function(a){return function(){var b,c,d,e;return d=arguments[0],b=2<=arguments.length?hb.call(arguments,1):[],"object"==typeof d&&b.length&&(c=d,e=b[0],d=function(){return c[e].apply(c,arguments)},b=b.slice(1)),a.apply(null,[d].concat(hb.call(b)))}},N=function(b,c){return eb(function(){var d,e,f;return e=arguments[0],d=2<=arguments.length?hb.call(arguments,1):[],f=V(c,[function(a,b){return e.apply(null,hb.call(a).concat([b]))}]),db.apply(null,[a,b,e].concat(hb.call(d),[a.combineAsArray(d).flatMap(f)]))})},a.fromCallback=N("fromCallback",function(){var b,c;return c=arguments[0],b=2<=arguments.length?hb.call(arguments,1):[],a.fromBinder(function(a){return O(c,b)(a),U},function(a){return[a,B()]})}),a.fromNodeCallback=N("fromNodeCallback",function(){var b,c;return c=arguments[0],b=2<=arguments.length?hb.call(arguments,1):[],a.fromBinder(function(a){return O(c,b)(a),U},function(a,b){return a?[new i(a),B()]:[b,B()]})}),a.fromPoll=function(b,c){return db(a,"fromPoll",b,c,a.fromBinder(function(c){var d;return d=a.scheduler.setInterval(c,b),function(){return a.scheduler.clearInterval(d)}},c))},a.interval=function(b,c){return null==c&&(c={}),db(a,"interval",b,c,a.fromPoll(b,function(){return T(c)}))},a.constant=function(b){return new q(A(a,"constant",b),function(a){return a(H(b)),a(B()),U})},a.never=function(){return db(a,"never",a.fromArray([]))},a.once=function(b){return db(a,"once",b,a.fromArray([b]))},a.fromArray=function(b){var c;return c=0,new k(A(a,"fromArray",b),function(d){var e,f,g;for(f=!1,e=a.more;e!==a.noMore&&!f;)c>=b.length?(d(B()),e=a.noMore):(g=b[c++],e=d($(g)));return function(){return f=!0}})},a.mergeAll=function(){var b;return b=1<=arguments.length?hb.call(arguments,0):[],I(b[0])&&(b=b[0]),b.length?new k(A.apply(null,[a,"mergeAll"].concat(hb.call(b))),function(c){var d,e,f;return d=0,f=function(e){return function(f){return e.subscribeInternal(function(e){var g;return e.isEnd()?(d++,d===b.length?c(B()):a.more):(g=c(e),g===a.noMore&&f(),g)})}},e=fb.map(f,b),x.apply(null,e)}):a.never()},a.zipAsArray=function(){var b;return b=1<=arguments.length?hb.call(arguments,0):[],I(b[0])&&(b=b[0]),db.apply(null,[a,"zipAsArray"].concat(hb.call(b),[a.zipWith(b,function(){var a;return a=1<=arguments.length?hb.call(arguments,0):[]})]))},a.zipWith=function(){var b,c,d;return b=arguments[0],c=2<=arguments.length?hb.call(arguments,1):[],K(b)||(d=[b,c[0]],c=d[0],b=d[1]),c=fb.map(function(a){return a.toEventStream()},c),db.apply(null,[a,"zipWith",b].concat(hb.call(c),[a.when(c,b)]))},a.groupSimultaneous=function(){var c,d,e;return e=1<=arguments.length?hb.call(arguments,0):[],1===e.length&&I(e[0])&&(e=e[0]),d=function(){var a,d,f;for(f=[],a=0,d=e.length;d>a;a++)c=e[a],f.push(new b(c));return f}(),db.apply(null,[a,"groupSimultaneous"].concat(hb.call(e),[a.when(d,function(){var a;return a=1<=arguments.length?hb.call(arguments,0):[]})]))},a.combineAsArray=function(){var b,c,d,e,f,g,h;for(f=1<=arguments.length?hb.call(arguments,0):[],1===f.length&&I(f[0])&&(f=f[0]),b=g=0,h=f.length;h>g;b=++g)e=f[b],L(e)||(f[b]=a.constant(e));return f.length?(d=function(){var a,b,d;for(d=[],a=0,b=f.length;b>a;a++)c=f[a],d.push(new t(c,!0,c.subscribeInternal));return d}(),db.apply(null,[a,"combineAsArray"].concat(hb.call(f),[a.when(d,function(){var a;return a=1<=arguments.length?hb.call(arguments,0):[]}).toProperty()]))):a.constant([])},a.onValues=function(){var b,c,d;return c=2<=arguments.length?hb.call(arguments,0,d=arguments.length-1):(d=0,[]),b=arguments[d++],a.combineAsArray(c).onValues(b)},a.combineWith=function(){var b,c;return b=arguments[0],c=2<=arguments.length?hb.call(arguments,1):[],db.apply(null,[a,"combineWith",b].concat(hb.call(c),[a.combineAsArray(c).map(function(a){return b.apply(null,a)})]))},a.combineTemplate=function(b){var c,d,e,f,g,h,i,j,k,l;return i=[],l=[],h=function(a){return a[a.length-1]},k=function(a,b,c){return h(a)[b]=c},c=function(a,b){return function(c,d){return k(c,a,d[b])}},g=function(a,b){return function(c){return k(c,a,b)}},j=function(a){return I(a)?[]:{}},e=function(a,b){var d,e;return L(b)?(l.push(b),i.push(c(a,l.length-1))):b!==Object(b)||"function"==typeof b||b instanceof RegExp||b instanceof Date?i.push(g(a,b)):(e=function(a){return function(c){var d;return d=j(b),k(c,a,d),c.push(d)}},d=function(a){return a.pop()},i.push(e(a)),f(b),i.push(d))},f=function(a){return fb.each(a,e)},f(b),d=function(a){var c,d,e,f,g;for(e=j(b),c=[e],f=0,g=i.length;g>f;f++)(d=i[f])(c,a);return e},db(a,"combineTemplate",b,a.combineAsArray(l).map(d))},a.retry=function(b){var c,d,e,f,g,h;if(!K(b.source))throw new l("'source' option has to be a function");return h=b.source,f=b.retries||0,e=b.maxRetries||f,c=b.delay||function(){return 0},d=b.isRetryable||function(){return!0},g=function(b){var g,i;return i={source:h,retries:f-1,maxRetries:e,delay:c,isRetryable:d},g=function(){return a.retry(i)},a.later(c(b)).filter(!1).concat(a.once().flatMap(g))},db(a,"retry",b,h().flatMapError(function(b){return d(b)&&f>0?g({error:b,retriesDone:e-f}):a.once(new i(b))}))},C=0,j=function(){function a(){this.id=++C}return a.prototype.isEvent=function(){return!0},a.prototype.isEnd=function(){return!1},a.prototype.isInitial=function(){return!1},a.prototype.isNext=function(){return!1},a.prototype.isError=function(){return!1},a.prototype.hasValue=function(){return!1},a.prototype.filter=function(){return!0},a.prototype.inspect=function(){return this.toString()},a.prototype.log=function(){return this.toString()},a}(),n=function(a){function b(a){b.__super__.constructor.call(this),this.value=K(a)?fb.cached(a):fb.always(a)}return jb(b,a),b.prototype.isNext=function(){return!0},b.prototype.hasValue=function(){return!0},b.prototype.fmap=function(a){var b;return b=this.value,this.apply(function(){return a(b())})},b.prototype.apply=function(a){return new b(a)},b.prototype.filter=function(a){return a(this.value())},b.prototype.toString=function(){return fb.toString(this.value())},b.prototype.log=function(){return this.value()},b}(j),m=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return jb(b,a),b.prototype.isInitial=function(){return!0},b.prototype.isNext=function(){return!1},b.prototype.apply=function(a){return new b(a)},b.prototype.toNext=function(){return new n(this.value)},b}(n),h=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return jb(b,a),b.prototype.isEnd=function(){return!0},b.prototype.fmap=function(){return this},b.prototype.apply=function(){return this},b.prototype.toString=function(){return"<end>"},b}(j),i=function(a){function b(a){this.error=a}return jb(b,a),b.prototype.isError=function(){return!0},b.prototype.fmap=function(){return this},b.prototype.apply=function(){return this},b.prototype.toString=function(){return"<error> "+fb.toString(this.error)},b}(j),G=0,p=function(){function b(a){this.flatMapError=kb(this.flatMapError,this),this.id=++G,db(a,this),this.initialDesc=this.desc}return b.prototype.onValue=function(){var a;return a=P(arguments),this.subscribe(function(b){return b.hasValue()?a(b.value()):void 0})},b.prototype.onValues=function(a){return this.onValue(function(b){return a.apply(null,b)})},b.prototype.onError=function(){var a;return a=P(arguments),this.subscribe(function(b){return b.isError()?a(b.error):void 0})},b.prototype.onEnd=function(){var a;return a=P(arguments),this.subscribe(function(b){return b.isEnd()?a():void 0})},b.prototype.errors=function(){return db(this,"errors",this.filter(function(){return!1}))},b.prototype.filter=function(){var b,c;return c=arguments[0],b=2<=arguments.length?hb.call(arguments,1):[],z(this,c,b,function(b){return db(this,"filter",b,this.withHandler(function(c){return c.filter(b)?this.push(c):a.more}))})},b.prototype.takeWhile=function(){var b,c;return c=arguments[0],b=2<=arguments.length?hb.call(arguments,1):[],z(this,c,b,function(b){return db(this,"takeWhile",b,this.withHandler(function(c){return c.filter(b)?this.push(c):(this.push(B()),a.noMore)}))})},b.prototype.endOnError=function(){var a,b;return b=arguments[0],a=2<=arguments.length?hb.call(arguments,1):[],null==b&&(b=!0),z(this,b,a,function(a){return db(this,"endOnError",this.withHandler(function(b){return b.isError()&&a(b.error)?(this.push(b),this.push(B())):this.push(b)}))})},b.prototype.take=function(b){return 0>=b?a.never():db(this,"take",b,this.withHandler(function(c){return c.hasValue()?(b--,b>0?this.push(c):(0===b&&this.push(c),this.push(B()),a.noMore)):this.push(c)}))},b.prototype.map=function(){var a,b;return b=arguments[0],a=2<=arguments.length?hb.call(arguments,1):[],b instanceof q?b.sampledBy(this,F):z(this,b,a,function(a){return db(this,"map",a,this.withHandler(function(b){return this.push(b.fmap(a))}))})},b.prototype.mapError=function(){var a;return a=P(arguments),db(this,"mapError",a,this.withHandler(function(b){return this.push(b.isError()?T(a(b.error)):b)}))},b.prototype.mapEnd=function(){var b;return b=P(arguments),db(this,"mapEnd",b,this.withHandler(function(c){return c.isEnd()?(this.push(T(b(c))),this.push(B()),a.noMore):this.push(c)}))},b.prototype.doAction=function(){var a;return a=P(arguments),db(this,"doAction",a,this.withHandler(function(b){return b.hasValue()&&a(b.value()),this.push(b)}))},b.prototype.skip=function(b){return db(this,"skip",b,this.withHandler(function(c){return c.hasValue()&&b>0?(b--,a.more):this.push(c)}))},b.prototype.skipDuplicates=function(a){return null==a&&(a=function(a,b){return a===b}),db(this,"skipDuplicates",this.withStateMachine(o,function(b,c){return c.hasValue()?c.isInitial()||b===o||!a(b.get(),c.value())?[new s(c.value()),[c]]:[b,[]]:[b,[c]]}))},b.prototype.skipErrors=function(){return db(this,"skipErrors",this.withHandler(function(b){return b.isError()?a.more:this.push(b)}))},b.prototype.withStateMachine=function(b,c){var d;return d=b,db(this,"withStateMachine",b,c,this.withHandler(function(b){var e,f,g,h,i,j,k;for(e=c(d,b),f=e[0],h=e[1],d=f,i=a.more,j=0,k=h.length;k>j;j++)if(g=h[j],i=this.push(g),i===a.noMore)return i;return i}))},b.prototype.scan=function(b,c,d){var e,f,g,h;return null==d&&(d={}),f=Z(c),c=d.lazyF?f:function(a,b){return f(a(),b())},e=bb(b).map(function(a){return fb.always(a)}),h=function(b){return function(f){var h,i,j,k;return h=!1,k=U,i=a.more,j=function(){return h?void 0:e.forEach(function(b){return h=!0,i=f(new m(b)),i===a.noMore?(k(),k=U):void 0})},k=b.subscribeInternal(function(b){var g,k;return b.hasValue()?h&&b.isInitial()?a.more:(b.isInitial()||j(),h=!0,k=e.getOrElse(function(){return void 0}),g=fb.cached(function(){return c(k,b.value)}),e=new s(g),d.eager&&g(),f(b.apply(g))):(b.isEnd()&&(i=j()),i!==a.noMore?f(b):void 0)}),u.whenDoneWith(g,j),k}}(this),g=new q(A(this,"scan",b,c),h)},b.prototype.fold=function(a,b,c){return db(this,"fold",a,b,this.scan(a,b,c).sampledBy(this.filter(!1).mapEnd().toProperty()))},b.prototype.zip=function(b,c){return null==c&&(c=Array),db(this,"zip",b,a.zipWith([this,b],c))},b.prototype.diff=function(a,b){return b=Z(b),db(this,"diff",a,b,this.scan([a],function(a,c){return[c,b(a[0],c)]}).filter(function(a){return 2===a.length}).map(function(a){return a[1]}))},b.prototype.flatMap=function(){return E(this,S(arguments))},b.prototype.flatMapFirst=function(){return E(this,S(arguments),!0)},b.prototype.flatMapWithConcurrencyLimit=function(){var a,b;return b=arguments[0],a=2<=arguments.length?hb.call(arguments,1):[],db.apply(null,[this,"flatMapWithConcurrencyLimit",b].concat(hb.call(a),[E(this,S(a),!1,b)]))},b.prototype.flatMapLatest=function(){var a,b;return a=S(arguments),b=this.toEventStream(),db(this,"flatMapLatest",a,b.flatMap(function(c){return R(a(c)).takeUntil(b)}))},b.prototype.flatMapError=function(b){return db(this,"flatMapError",b,this.mapError(function(a){return new i(a)}).flatMap(function(c){return c instanceof i?b(c.error):a.once(c)}))},b.prototype.flatMapConcat=function(){return db.apply(null,[this,"flatMapConcat"].concat(hb.call(arguments),[this.flatMapWithConcurrencyLimit.apply(this,[1].concat(hb.call(arguments)))]))},b.prototype.bufferingThrottle=function(b){return db(this,"bufferingThrottle",b,this.flatMapConcat(function(c){return a.once(c).concat(a.later(b).filter(!1))}))},b.prototype.not=function(){return db(this,"not",this.map(function(a){return!a}))},b.prototype.log=function(){var a;return a=1<=arguments.length?hb.call(arguments,0):[],this.subscribe(function(b){return"undefined"!=typeof console&&null!==console&&"function"==typeof console.log?console.log.apply(console,hb.call(a).concat([b.log()])):void 0}),this},b.prototype.slidingWindow=function(a,b){return null==b&&(b=0),db(this,"slidingWindow",a,b,this.scan([],function(b,c){return b.concat([c]).slice(-a)}).filter(function(a){return a.length>=b}))},b.prototype.combine=function(b,c){var d;return d=Z(c),db(this,"combine",b,c,a.combineAsArray(this,b).map(function(a){return d(a[0],a[1])}))},b.prototype.decode=function(b){return db(this,"decode",b,this.combine(a.combineTemplate(b),function(a,b){return b[a]}))},b.prototype.awaiting=function(b){return db(this,"awaiting",b,a.groupSimultaneous(this,b).map(function(a){var b,c;return b=a[0],c=a[1],0===c.length}).toProperty(!1).skipDuplicates())},b.prototype.name=function(a){return this._name=a,this},b.prototype.withDescription=function(){return A.apply(null,arguments).apply(this)},b.prototype.toString=function(){return this._name?this._name:this.desc.toString()},b.prototype.internalDeps=function(){return this.initialDesc.deps()},b}(),p.prototype.reduce=p.prototype.fold,p.prototype.assign=p.prototype.onValue,p.prototype.inspect=p.prototype.toString,E=function(b,c,e,f){var g,h,i;return i=[b],g=[],h=new k(A(b,"flatMap"+(e?"First":""),c),function(h){var i,j,k,l,n;return k=new d,l=[],n=function(b){var d;return d=R(c(b.value())),g.push(d),k.add(function(b,c){return d.subscribeInternal(function(e){var f;return e.isEnd()?(fb.remove(d,g),j(),i(c),a.noMore):(e instanceof m&&(e=e.toNext()),f=h(e),f===a.noMore&&b(),f)})})},j=function(){var a;return a=l.shift(),a?n(a):void 0},i=function(a){return a(),k.empty()?h(B()):void 0},k.add(function(c,d){return b.subscribeInternal(function(b){return b.isEnd()?i(d):b.isError()?h(b):e&&k.count()>1?a.more:k.unsubscribed?a.noMore:f&&k.count()>f?l.push(b):n(b)})}),k.unsubscribe}),h.internalDeps=function(){return g.length?i.concat(g):i},h},k=function(b){function c(a,b){var d;K(a)&&(b=a,a=[]),c.__super__.constructor.call(this,a),d=new g(b),this.subscribeInternal=d.subscribe,this.subscribe=u.wrappedSubscribe(this),this.hasSubscribers=d.hasSubscribers,X(this)}return jb(c,b),c.prototype.delay=function(b){return db(this,"delay",b,this.flatMap(function(c){return a.later(b,c)}))},c.prototype.debounce=function(b){return db(this,"debounce",b,this.flatMapLatest(function(c){return a.later(b,c)}))},c.prototype.debounceImmediate=function(b){return db(this,"debounceImmediate",b,this.flatMapFirst(function(c){return a.once(c).concat(a.later(b).filter(!1))}))},c.prototype.throttle=function(a){return db(this,"throttle",a,this.bufferWithTime(a).map(function(a){return a[a.length-1]}))},c.prototype.bufferWithTime=function(a){return db(this,"bufferWithTime",a,this.bufferWithTimeOrCount(a,Number.MAX_VALUE))},c.prototype.bufferWithCount=function(a){return db(this,"bufferWithCount",a,this.bufferWithTimeOrCount(void 0,a))},c.prototype.bufferWithTimeOrCount=function(a,b){var c;return c=function(c){return c.values.length===b?c.flush():void 0!==a?c.schedule():void 0},db(this,"bufferWithTimeOrCount",a,b,this.buffer(a,c,c))},c.prototype.buffer=function(b,c,d){var e,f,g;return null==c&&(c=U),null==d&&(d=U),e={scheduled:!1,end:void 0,values:[],flush:function(){var b;if(this.scheduled=!1,this.values.length>0){if(b=this.push(T(this.values)),this.values=[],null!=this.end)return this.push(this.end);if(b!==a.noMore)return d(this)}else if(null!=this.end)return this.push(this.end)},schedule:function(){return this.scheduled?void 0:(this.scheduled=!0,b(function(a){return function(){return a.flush()}}(this)))}},g=a.more,K(b)||(f=b,b=function(b){return a.scheduler.setTimeout(b,f)}),db(this,"buffer",this.withHandler(function(a){return e.push=this.push,a.isError()?g=this.push(a):a.isEnd()?(e.end=a,e.scheduled||e.flush()):(e.values.push(a.value()),c(e)),g}))},c.prototype.merge=function(b){var c;return c=this,db(c,"merge",b,a.mergeAll(this,b))},c.prototype.toProperty=function(a){return 0===arguments.length&&(a=o),db(this,"toProperty",a,this.scan(a,M,{lazyF:!0}))},c.prototype.toEventStream=function(){return this},c.prototype.sampledBy=function(a,b){return db(this,"sampledBy",a,b,this.toProperty().sampledBy(a,b))},c.prototype.concat=function(a){var b;return b=this,new c(A(b,"concat",a),function(c){var d,e;return e=U,d=b.subscribeInternal(function(b){return b.isEnd()?e=a.subscribeInternal(c):c(b)}),function(){return d(),e()}})},c.prototype.takeUntil=function(b){var c;return c={},db(this,"takeUntil",b,a.groupSimultaneous(this.mapEnd(c),b.skipErrors()).withHandler(function(d){var e,f,g,h,i,j;if(d.hasValue()){if(j=d.value(),e=j[0],b=j[1],b.length)return this.push(B());for(f=a.more,h=0,i=e.length;i>h;h++)g=e[h],f=this.push(g===c?B():T(g));return f}return this.push(d)}))},c.prototype.skipUntil=function(a){var b;return b=a.take(1).map(!0).toProperty(!1),db(this,"skipUntil",a,this.filter(b))},c.prototype.skipWhile=function(){var b,c,d;return c=arguments[0],b=2<=arguments.length?hb.call(arguments,1):[],d=!1,z(this,c,b,function(b){return db(this,"skipWhile",b,this.withHandler(function(c){return!d&&c.hasValue()&&b(c.value())?a.more:(c.hasValue()&&(d=!0),this.push(c))}))})},c.prototype.holdWhen=function(b){var c,d,e;return e=b.startWith(!1),d=e.filter(function(a){return!a}),c=e.filter(fb.id),db(this,"holdWhen",b,this.filter(!1).merge(e.flatMapConcat(function(b){return function(e){return e?b.scan([],function(a,b){return a.concat(b)},{eager:!0}).sampledBy(d).take(1).flatMap(a.fromArray):b.takeUntil(c)}}(this))))},c.prototype.startWith=function(b){return db(this,"startWith",b,a.once(b).concat(this))},c.prototype.withHandler=function(a){var b;return b=new g(this.subscribeInternal,a),new c(A(this,"withHandler",a),b.subscribe)},c}(p),q=function(b){function c(a,b,d){K(a)&&(d=b,b=a,a=[]),c.__super__.constructor.call(this,a),this.subscribeInternal=d===!0?b:new r(this,b,d).subscribe,this.subscribe=u.wrappedSubscribe(this),X(this)}return jb(c,b),c.prototype.sampledBy=function(b,d){var e,f,g,h,i;return null!=d?d=Z(d):(e=!0,d=function(a){return a()}),i=new t(this,!1,this.subscribeInternal,e),g=new t(b,!0,b.subscribeInternal,e),h=a.when([i,g],d),f=b instanceof c?h.toProperty():h,db(this,"sampledBy",b,d,f)},c.prototype.sample=function(b){return db(this,"sample",b,this.sampledBy(a.interval(b,{})))},c.prototype.changes=function(){return new k(A(this,"changes"),function(a){return function(b){return a.subscribeInternal(function(a){return a.isInitial()?void 0:b(a)})}}(this))},c.prototype.withHandler=function(a){return new c(A(this,"withHandler",a),this.subscribeInternal,a)},c.prototype.toProperty=function(){return this},c.prototype.toEventStream=function(){return new k(A(this,"toEventStream"),function(a){return function(b){return a.subscribeInternal(function(a){return a.isInitial()&&(a=a.toNext()),b(a)})}}(this))},c.prototype.and=function(a){return db(this,"and",a,this.combine(a,function(a,b){return a&&b}))},c.prototype.or=function(a){return db(this,"or",a,this.combine(a,function(a,b){return a||b}))},c.prototype.delay=function(a){return this.delayChanges("delay",a,function(b){return b.delay(a)})},c.prototype.debounce=function(a){return this.delayChanges("debounce",a,function(b){return b.debounce(a)})},c.prototype.throttle=function(a){return this.delayChanges("throttle",a,function(b){return b.throttle(a)})},c.prototype.delayChanges=function(){var a,b,c;return a=2<=arguments.length?hb.call(arguments,0,c=arguments.length-1):(c=0,[]),b=arguments[c++],db.apply(null,[this].concat(hb.call(a),[v(this,b(this.changes()))]))},c.prototype.takeUntil=function(a){var b;return b=this.changes().takeUntil(a),db(this,"takeUntil",a,v(this,b))},c.prototype.startWith=function(a){return db(this,"startWith",a,this.scan(a,function(a,b){return b}))},c.prototype.bufferingThrottle=function(){var a;return(a=c.__super__.bufferingThrottle.apply(this,arguments)).bufferingThrottle.apply(a,arguments).toProperty()},c}(p),z=function(a,b,c,d){var e;return b instanceof q?(e=b.sampledBy(a,function(a,b){return[a,b]}),d.apply(e,[function(a){var b,c;return b=a[0],c=a[1],b}]).map(function(a){var b,c;return b=a[0],c=a[1]})):(b=O(b,c),d.apply(a,[b]))},v=function(b,c){var d;return d=new k(A(b,"justInitValue"),function(c){var e,f;return f=void 0,e=b.subscribeInternal(function(b){return b.isEnd()||(f=b),a.noMore}),u.whenDoneWith(d,function(){return null!=f&&c(f),c(B())}),e}),d.concat(c).toProperty()},g=function(){function b(b,c){var d,e,f,g,h,i,j,k;null==b&&(b=function(){return U}),j=[],h=[],g=!1,d=!1,this.hasSubscribers=function(){return j.length>0},e=void 0,k=U,i=function(a){return j=fb.without(a,j)},f=function(b){var c,d,f,l,m,n;if(g)return h.push(b),a.more;if(b!==e){b.isError()&&(e=b),f=!1;try{for(g=!0,l=j,m=0,n=l.length;n>m;m++)d=l[m],c=d.sink(b),(c===a.noMore||b.isEnd())&&i(d);f=!0}finally{g=!1,f||(h=[])}for(f=!0;h.length;)b=h.shift(),this.push(b);return this.hasSubscribers()?a.more:(k(),a.noMore)}},this.push=function(a){return function(b){return u.inTransaction(b,a,f,[b])}}(this),null==c&&(c=function(a){return this.push(a)}),this.handleEvent=function(a){return function(b){return b.isEnd()&&(d=!0),c.apply(a,[b])}}(this),this.subscribe=function(a){return function(c){var e,f;return d?(c(B()),U):(e={sink:c},j.push(e),1===j.length&&(f=b(a.handleEvent),k=function(){return f(),k=U}),function(){return i(e),a.hasSubscribers()?void 0:k()})}}(this)}return b}(),r=function(b){function c(b,d,e){var f,g,h,i;c.__super__.constructor.call(this,d,e),f=o,g=void 0,i=this.push,d=this.subscribe,h=!1,this.push=function(a){return function(b){return b.isEnd()&&(h=!0),b.hasValue()&&(f=new s(b),g=u.currentEventId()),i.apply(a,[b])}}(this),this.subscribe=function(c){return function(e){var i,j,k,l,m;return j=!1,l=a.more,k=function(){return l===a.noMore?U:h?(e(B()),U):d.apply(this,[e])},f.isDefined&&(c.hasSubscribers()||h)?(i=u.currentEventId(),m=g,!h&&m&&i&&i!==m?(u.whenDoneWith(b,function(){return g===m?e(H(f.get().value())):void 0}),k()):(u.inTransaction(void 0,c,function(){return l=e(H(f.get().value()))},[]),k())):k()}}(this)}return jb(c,b),c}(g),c=function(b){function c(){var b,d,e,f,g,h,j,k;e=void 0,h=[],b=!1,d=function(b){return function(c){return c.isEnd()?(k(b),a.noMore):e(c)}},j=function(){var a,b,c;for(b=0,c=h.length;c>b;b++)a=h[b],"function"==typeof a.unsub&&a.unsub();return void 0},g=function(a){return a.unsub=a.input.subscribeInternal(d(a.input))},k=function(a){var b,c,d,e;for(b=d=0,e=h.length;e>d;b=++d)if(c=h[b],c.input===a)return"function"==typeof c.unsub&&c.unsub(),void h.splice(b,1)},f=function(a){var b,c,d,f;for(e=a,f=w(h),c=0,d=f.length;d>c;c++)b=f[c],g(b);return j},c.__super__.constructor.call(this,A(a,"Bus"),f),this.plug=function(a){var c;if(!b)return c={input:a},h.push(c),null!=e&&g(c),function(){return k(a)}},this.push=function(a){return"function"==typeof e?e(T(a)):void 0},this.error=function(a){return"function"==typeof e?e(new i(a)):void 0},this.end=function(){return b=!0,j(),"function"==typeof e?e(B()):void 0}}return jb(c,b),c}(k),t=function(){function a(a,b,c,d){this.obs=a,this.sync=b,this.subscribe=c,this.lazy=null!=d?d:!1,this.queue=[],null==this.subscribe&&(this.subscribe=this.obs.subscribeInternal)}return a.prototype.toString=function(){return this.obs.toString.call(this)},a.prototype.markEnded=function(){return this.ended=!0},a.prototype.consume=function(){return this.lazy?fb.always(this.queue[0]):this.queue[0]},a.prototype.push=function(a){return this.queue=[a]},a.prototype.mayHave=function(){return!0},a.prototype.hasAtLeast=function(){return this.queue.length},a.prototype.flatten=!0,a}(),e=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return jb(b,a),b.prototype.consume=function(){return this.queue.shift()},b.prototype.push=function(a){return this.queue.push(a)},b.prototype.mayHave=function(a){return!this.ended||this.queue.length>=a},b.prototype.hasAtLeast=function(a){return this.queue.length>=a},b.prototype.flatten=!1,b}(t),b=function(a){function b(a){this.obs=a,b.__super__.constructor.call(this,this.obs,!0,this.obs.subscribeInternal)}return jb(b,a),b.prototype.consume=function(){var a;return a=this.queue,this.queue=[],function(){return a}},b.prototype.push=function(a){return this.queue.push(a())},b.prototype.hasAtLeast=function(){return!0},b}(t),t.isTrigger=function(a){return a instanceof t?a.sync:a instanceof k},t.fromObservable=function(a){return a instanceof t?a:a instanceof q?new t(a,!1):new e(a,!0)},A=function(){var a,b,c;return b=arguments[0],c=arguments[1],a=3<=arguments.length?hb.call(arguments,2):[],(b||c)instanceof f?b||c:new f(b,c,a)},D=function(a){return I(a)?fb.flatMap(D,a):L(a)?[a]:a instanceof t?[a.obs]:[]},f=function(){function a(a,b,c){this.context=a,this.method=b,this.args=c,this.cached=void 0}return a.prototype.deps=function(){return this.cached||(this.cached=D([this.context].concat(this.args)))},a.prototype.apply=function(a){return a.desc=this,a},a.prototype.toString=function(){return fb.toString(this.context)+"."+fb.toString(this.method)+"("+fb.map(fb.toString,this.args)+")"},a}(),db=function(){var a,b,c;return a=2<=arguments.length?hb.call(arguments,0,c=arguments.length-1):(c=0,[]),b=arguments[c++],A.apply(null,a).apply(b)},a.when=function(){var b,c,d,e,f,g,h,i,j,l,m,n,o,p,q,r,s,v,w,z;if(l=1<=arguments.length?hb.call(arguments,0):[],0===l.length)return a.never();for(f=l.length,q="when: expecting arguments in the form (Observable+,function)+",o=[],j=[],c=0;f>c;){for(i=fb.toArray(l[c]),b=l[c+1],h={f:K(b)?b:function(){return b},ixs:[]},p=!1,r=0,v=i.length;v>r;r++){for(n=i[r],d=fb.indexOf(o,n),p||(p=t.isTrigger(n)),0>d&&(o.push(n),d=o.length-1),z=h.ixs,s=0,w=z.length;w>s;s++)e=z[s],e.index===d&&e.count++;h.ixs.push({index:d,count:1})}i.length>0&&j.push(h),c+=2}return o.length?(o=fb.map(t.fromObservable,o),g=fb.any(o,function(a){return a.flatten})&&y(fb.map(function(a){return a.obs},o)),m=new k(A.apply(null,[a,"when"].concat(hb.call(l))),function(b){var d,e,f,h,i,k,l;return l=[],f=!1,h=function(a){var b,d,e;for(e=a.ixs,b=0,d=e.length;d>b;b++)if(c=e[b],!o[c.index].hasAtLeast(c.count))return!1;return!0},e=function(a){return!a.sync||a.ended},d=function(a){var b,d,e;for(e=a.ixs,b=0,d=e.length;d>b;b++)if(c=e[b],!o[c.index].mayHave(c.count))return!0},i=function(a){return!a.source.flatten},k=function(k){return function(n){var p,q,r;return q=function(){return u.whenDoneWith(m,p)},r=function(){var d,e,f,g,k,m;if(!(l.length>0))return a.more;for(f=a.more,g=l.pop(),k=0,m=j.length;m>k;k++)if(e=j[k],h(e))return d=function(){var a,b,d,f;for(d=e.ixs,f=[],a=0,b=d.length;b>a;a++)c=d[a],f.push(o[c.index].consume());return f}(),f=b(g.e.apply(function(){var a,b;return b=function(){var b,c,e;for(e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a());return e}(),e.f.apply(e,b)})),l.length&&(l=fb.filter(i,l)),f===a.noMore?f:r()},p=function(){var c;return c=r(),f&&(f=!1,(fb.all(o,e)||fb.all(j,d))&&(c=a.noMore,b(B()))),c===a.noMore&&n(),c},k.subscribe(function(c){var d;return c.isEnd()?(f=!0,k.markEnded(),q()):c.isError()?d=b(c):(k.push(c.value),k.sync&&(l.push({source:k,e:c}),g||u.hasWaiters()?q():p())),d===a.noMore&&n(),d||a.more})}},x.apply(null,function(){var a,b,c;for(c=[],a=0,b=o.length;b>a;a++)n=o[a],c.push(k(n));return c}())})):a.never()},y=function(a,b){var c;return null==b&&(b=[]),c=function(a){var d;return fb.contains(b,a)?!0:(d=a.internalDeps(),d.length?(b.push(a),fb.any(d,c)):(b.push(a),!1))},fb.any(a,c)},a.update=function(){var b,c,d,e;for(c=arguments[0],e=2<=arguments.length?hb.call(arguments,1):[],d=function(a){return function(){var b;return b=1<=arguments.length?hb.call(arguments,0):[],function(c){return a.apply(null,[c].concat(b))}}},b=e.length-1;b>0;)e[b]instanceof Function||(e[b]=function(a){return function(){return a}}(e[b])),e[b]=d(e[b]),b-=2;return db.apply(null,[a,"update",c].concat(hb.call(e),[a.when.apply(a,e).scan(c,function(a,b){return b(a)})]))},x=function(){var a;return a=1<=arguments.length?hb.call(arguments,0):[],new d(a).unsubscribe},d=function(){function a(a){var b,c,d;for(null==a&&(a=[]),this.unsubscribe=kb(this.unsubscribe,this),this.unsubscribed=!1,this.subscriptions=[],this.starting=[],c=0,d=a.length;d>c;c++)b=a[c],this.add(b)}return a.prototype.add=function(a){var b,c,d;if(!this.unsubscribed)return b=!1,c=U,this.starting.push(a),d=function(d){return function(){return d.unsubscribed?void 0:(b=!0,d.remove(c),fb.remove(a,d.starting))}}(this),c=a(this.unsubscribe,d),this.unsubscribed||b||this.subscriptions.push(c),fb.remove(a,this.starting),c},a.prototype.remove=function(a){return this.unsubscribed?void 0:void 0!==fb.remove(a,this.subscriptions)?a():void 0},a.prototype.unsubscribe=function(){var a,b,c,d;if(!this.unsubscribed){for(this.unsubscribed=!0,d=this.subscriptions,b=0,c=d.length;c>b;b++)(a=d[b])();return this.subscriptions=[],this.starting=[]}},a.prototype.count=function(){return this.unsubscribed?0:this.subscriptions.length+this.starting.length},a.prototype.empty=function(){return 0===this.count()},a}(),a.CompositeUnsubscribe=d,s=function(){function a(a){this.value=a}return a.prototype.getOrElse=function(){return this.value},a.prototype.get=function(){return this.value},a.prototype.filter=function(b){return b(this.value)?new a(this.value):o | ||
},a.prototype.map=function(b){return new a(b(this.value))},a.prototype.forEach=function(a){return a(this.value)},a.prototype.isDefined=!0,a.prototype.toArray=function(){return[this.value]},a.prototype.inspect=function(){return"Some("+this.value+")"},a.prototype.toString=function(){return this.inspect()},a}(),o={getOrElse:function(a){return a},filter:function(){return o},map:function(){return o},forEach:function(){},isDefined:!1,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}},u=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n;return j=void 0,k=[],l={},c=[],b=function(a){return j?c.push(a):a()},m=function(a,b){var c;return j?(c=l[a.id],null==c?(c=l[a.id]=[b],k.push(a)):c.push(b)):b()},e=function(){for(;k.length>0;)g(0);return void 0},g=function(a){var b,c,d,e,g,h;for(c=k[a],d=c.id,e=l[d],k.splice(a,1),delete l[d],f(c),g=0,h=e.length;h>g;g++)(b=e[g])();return void 0},f=function(a){var b,c,d,e,h;for(c=a.internalDeps(),e=0,h=c.length;h>e;e++)b=c[e],f(b),l[b.id]&&(d=fb.indexOf(k,b),g(d));return void 0},i=function(a,b,d,f){var g,h,i,k;if(j)return d.apply(b,f);j=a;try{g=d.apply(b,f),e()}finally{for(j=void 0;c.length;)for(h=c,c=[],i=0,k=h.length;k>i;i++)(d=h[i])()}return g},d=function(){return j?j.id:void 0},n=function(c){return function(d){var e,f,g;return g=!1,e=function(){},f=function(){return g=!0,e()},e=c.subscribeInternal(function(c){return b(function(){var b;return g||(b=d(c),b!==a.noMore)?void 0:f()})}),f}},h=function(){return k.length>0},{whenDoneWith:m,hasWaiters:h,inTransaction:i,currentEventId:d,wrappedSubscribe:n}}(),a.EventStream=k,a.Property=q,a.Observable=p,a.Bus=c,a.Initial=m,a.Next=n,a.End=h,a.Error=i,U=function(){},M=function(a,b){return b()},F=function(a){return a},H=function(a){return new m(fb.always(a))},T=function(a){return new n(fb.always(a))},B=function(){return new h},$=function(a){return a instanceof j?a:T(a)},w=function(a){return a.slice(0)},K=function(a){return"function"==typeof a},I=function(a){return a instanceof Array},L=function(a){return a instanceof p},V=function(a,b){return function(){var c;return c=1<=arguments.length?hb.call(arguments,0):[],a.apply(null,b.concat(c))}},S=function(a){return 1===a.length&&L(a[0])?fb.always(a[0]):P(a)},P=function(a){return a=Array.prototype.slice.call(a),Q.apply(null,a)},Q=eb(function(){var a,b;return b=arguments[0],a=2<=arguments.length?hb.call(arguments,1):[],K(b)?a.length?V(b,a):b:J(b)?_(b,a):fb.always(b)}),O=function(a,b){return Q.apply(null,[a].concat(hb.call(b)))},R=function(b){return L(b)?b:a.once(b)},J=function(a){return"string"==typeof a&&a.length>1&&"."===a.charAt(0)},a.isFieldKey=J,_=function(a,b){var c,d;return d=a.slice(1).split("."),c=fb.map(cb(b),d),function(b){var d,e;for(d=0,e=c.length;e>d;d++)a=c[d],b=a(b);return b}},cb=function(a){return function(b){return function(c){var d;return null==c?void 0:(d=c[b],K(d)?d.apply(c,a):d)}}},ab=function(a){return a.slice(1)},Z=function(a){var b;return K(a)?a:J(a)?(b=ab(a),function(a,c){return a[b](c)}):void 0},bb=function(a){return a instanceof s||a===o?a:new s(a)},fb={indexOf:Array.prototype.indexOf?function(a,b){return a.indexOf(b)}:function(a,b){var c,d,e,f;for(c=e=0,f=a.length;f>e;c=++e)if(d=a[c],b===d)return c;return-1},indexWhere:function(a,b){var c,d,e,f;for(c=e=0,f=a.length;f>e;c=++e)if(d=a[c],b(d))return c;return-1},head:function(a){return a[0]},always:function(a){return function(){return a}},negate:function(a){return function(b){return!a(b)}},empty:function(a){return 0===a.length},tail:function(a){return a.slice(1,a.length)},filter:function(a,b){var c,d,e,f;for(c=[],e=0,f=b.length;f>e;e++)d=b[e],a(d)&&c.push(d);return c},map:function(a,b){var c,d,e,f;for(f=[],d=0,e=b.length;e>d;d++)c=b[d],f.push(a(c));return f},each:function(a,b){var c,d;for(c in a)d=a[c],b(c,d);return void 0},toArray:function(a){return I(a)?a:[a]},contains:function(a,b){return-1!==fb.indexOf(a,b)},id:function(a){return a},last:function(a){return a[a.length-1]},all:function(a,b){var c,d,e;for(null==b&&(b=fb.id),d=0,e=a.length;e>d;d++)if(c=a[d],!b(c))return!1;return!0},any:function(a,b){var c,d,e;for(null==b&&(b=fb.id),d=0,e=a.length;e>d;d++)if(c=a[d],b(c))return!0;return!1},without:function(a,b){return fb.filter(function(b){return b!==a},b)},remove:function(a,b){var c;return c=fb.indexOf(b,a),c>=0?b.splice(c,1):void 0},fold:function(a,b,c){var d,e,f;for(e=0,f=a.length;f>e;e++)d=a[e],b=c(b,d);return b},flatMap:function(a,b){return fb.fold(b,[],function(b,c){return b.concat(a(c))})},cached:function(a){var b;return b=o,function(){return b===o&&(b=a(),a=void 0),b}},toString:function(a){var b,c,d,e;try{return W++,null==a?"undefined":K(a)?"function":I(a)?W>5?"[..]":"["+fb.map(fb.toString,a).toString()+"]":null!=(null!=a?a.toString:void 0)&&a.toString!==Object.prototype.toString?a.toString():"object"==typeof a?W>5?"{..}":(c=function(){var c;c=[];for(d in a)ib.call(a,d)&&(e=function(){try{return a[d]}catch(c){return b=c}}(),c.push(fb.toString(d)+":"+fb.toString(e)));return c}(),"{"+c+"}"):a}finally{W--}}},W=0,a._=fb,a.scheduler={setTimeout:function(a,b){return setTimeout(a,b)},setInterval:function(a,b){return setInterval(a,b)},clearInterval:function(a){return clearInterval(a)},now:function(){return(new Date).getTime()}},"undefined"!=typeof define&&null!==define&&null!=define.amd?(define([],function(){return a}),this.Bacon=a):"undefined"!=typeof module&&null!==module&&null!=module.exports?(module.exports=a,a.Bacon=a):this.Bacon=a}).call(this); | ||
(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,ab,bb,cb,db,eb,fb,gb,hb=[].slice,ib={}.hasOwnProperty,jb=function(a,b){function c(){this.constructor=a}for(var d in b)ib.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},kb=function(a,b){return function(){return a.apply(b,arguments)}};a={toString:function(){return"Bacon"}},a.version="0.7.28",l=("undefined"!=typeof global&&null!==global?global:this).Error,a.fromBinder=function(b,c){return null==c&&(c=fb.id),new k(A(a,"fromBinder",b,c),function(d){var e,f,g;return g=!1,e=function(){return"undefined"!=typeof f&&null!==f?(g||f(),g=!0):void 0},f=b(function(){var b,g,h,i,k,l;for(b=1<=arguments.length?hb.call(arguments,0):[],i=c.apply(this,b),I(i)&&fb.last(i)instanceof j||(i=[i]),h=a.more,k=0,l=i.length;l>k;k++)if(g=i[k],h=d(g=$(g)),h===a.noMore||g.isEnd())return null!=f?e():a.scheduler.setTimeout(e,0),h;return h}),e})},a.$={},a.$.asEventStream=function(b,c,d){var e;return K(c)&&(e=[c,void 0],d=e[0],c=e[1]),db(this.selector||this,"asEventStream",b,a.fromBinder(function(a){return function(d){return a.on(b,c,d),function(){return a.off(b,c,d)}}}(this),d))},null!=(gb="undefined"!=typeof jQuery&&null!==jQuery?jQuery:"undefined"!=typeof Zepto&&null!==Zepto?Zepto:void 0)&&(gb.fn.asEventStream=a.$.asEventStream),a.fromEventTarget=function(b,c,d){var e,f,g,h,i,j;return e=null!=(g=b.addEventListener)?g:null!=(h=b.addListener)?h:b.bind,f=null!=(i=b.removeEventListener)?i:null!=(j=b.removeListener)?j:b.unbind,db(a,"fromEventTarget",b,c,a.fromBinder(function(a){return e.call(b,c,a),function(){return f.call(b,c,a)}},d))},a.fromPromise=function(b,c){return db(a,"fromPromise",b,a.fromBinder(function(a){return b.then(a,function(b){return a(new i(b))}),function(){return c&&"function"==typeof b.abort?b.abort():void 0}},function(a){return[a,B()]}))},a.noMore=["<no-more>"],a.more=["<more>"],a.later=function(b,c){return db(a,"later",b,c,a.fromPoll(b,function(){return[c,B()]}))},a.sequentially=function(b,c){var d;return d=0,db(a,"sequentially",b,c,a.fromPoll(b,function(){var a;return a=c[d++],d<c.length?a:d===c.length?[a,B()]:B()}))},a.repeatedly=function(b,c){var d;return d=0,db(a,"repeatedly",b,c,a.fromPoll(b,function(){return c[d++%c.length]}))},a.spy=function(a){return Y.push(a)},Y=[],X=function(a){var b,c,d;if(Y.length&&!X.running)try{for(X.running=!0,c=0,d=Y.length;d>c;c++)(b=Y[c])(a)}finally{delete X.running}return void 0},eb=function(a){return function(){var b,c,d,e;return d=arguments[0],b=2<=arguments.length?hb.call(arguments,1):[],"object"==typeof d&&b.length&&(c=d,e=b[0],d=function(){return c[e].apply(c,arguments)},b=b.slice(1)),a.apply(null,[d].concat(hb.call(b)))}},N=function(b,c){return eb(function(){var d,e,f;return e=arguments[0],d=2<=arguments.length?hb.call(arguments,1):[],f=V(c,[function(a,b){return e.apply(null,hb.call(a).concat([b]))}]),db.apply(null,[a,b,e].concat(hb.call(d),[a.combineAsArray(d).flatMap(f)]))})},a.fromCallback=N("fromCallback",function(){var b,c;return c=arguments[0],b=2<=arguments.length?hb.call(arguments,1):[],a.fromBinder(function(a){return O(c,b)(a),U},function(a){return[a,B()]})}),a.fromNodeCallback=N("fromNodeCallback",function(){var b,c;return c=arguments[0],b=2<=arguments.length?hb.call(arguments,1):[],a.fromBinder(function(a){return O(c,b)(a),U},function(a,b){return a?[new i(a),B()]:[b,B()]})}),a.fromPoll=function(b,c){return db(a,"fromPoll",b,c,a.fromBinder(function(c){var d;return d=a.scheduler.setInterval(c,b),function(){return a.scheduler.clearInterval(d)}},c))},a.interval=function(b,c){return null==c&&(c={}),db(a,"interval",b,c,a.fromPoll(b,function(){return T(c)}))},a.constant=function(b){return new q(A(a,"constant",b),function(a){return a(H(b)),a(B()),U})},a.never=function(){return new k(A(a,"never"),function(a){return a(B()),U})},a.once=function(b){return new k(A(a,"once",b),function(a){return a($(b)),a(B()),U})},a.fromArray=function(b){var c;return c=0,new k(A(a,"fromArray",b),function(d){var e,f,g;for(f=!1,e=a.more;e!==a.noMore&&!f;)c>=b.length?(d(B()),e=a.noMore):(g=b[c++],e=d($(g)));return function(){return f=!0}})},a.mergeAll=function(){var b;return b=1<=arguments.length?hb.call(arguments,0):[],I(b[0])&&(b=b[0]),b.length?new k(A.apply(null,[a,"mergeAll"].concat(hb.call(b))),function(c){var d,e,f;return d=0,f=function(e){return function(f){return e.dispatcher.subscribe(function(e){var g;return e.isEnd()?(d++,d===b.length?c(B()):a.more):(g=c(e),g===a.noMore&&f(),g)})}},e=fb.map(f,b),x.apply(null,e)}):a.never()},a.zipAsArray=function(){var b;return b=1<=arguments.length?hb.call(arguments,0):[],I(b[0])&&(b=b[0]),db.apply(null,[a,"zipAsArray"].concat(hb.call(b),[a.zipWith(b,function(){var a;return a=1<=arguments.length?hb.call(arguments,0):[]})]))},a.zipWith=function(){var b,c,d;return b=arguments[0],c=2<=arguments.length?hb.call(arguments,1):[],K(b)||(d=[b,c[0]],c=d[0],b=d[1]),c=fb.map(function(a){return a.toEventStream()},c),db.apply(null,[a,"zipWith",b].concat(hb.call(c),[a.when(c,b)]))},a.groupSimultaneous=function(){var c,d,e;return e=1<=arguments.length?hb.call(arguments,0):[],1===e.length&&I(e[0])&&(e=e[0]),d=function(){var a,d,f;for(f=[],a=0,d=e.length;d>a;a++)c=e[a],f.push(new b(c));return f}(),db.apply(null,[a,"groupSimultaneous"].concat(hb.call(e),[a.when(d,function(){var a;return a=1<=arguments.length?hb.call(arguments,0):[]})]))},a.combineAsArray=function(){var b,c,d,e,f,g,h;for(f=1<=arguments.length?hb.call(arguments,0):[],1===f.length&&I(f[0])&&(f=f[0]),b=g=0,h=f.length;h>g;b=++g)e=f[b],L(e)||(f[b]=a.constant(e));return f.length?(d=function(){var a,b,d;for(d=[],a=0,b=f.length;b>a;a++)c=f[a],d.push(new t(c,!0));return d}(),db.apply(null,[a,"combineAsArray"].concat(hb.call(f),[a.when(d,function(){var a;return a=1<=arguments.length?hb.call(arguments,0):[]}).toProperty()]))):a.constant([])},a.onValues=function(){var b,c,d;return c=2<=arguments.length?hb.call(arguments,0,d=arguments.length-1):(d=0,[]),b=arguments[d++],a.combineAsArray(c).onValues(b)},a.combineWith=function(){var b,c;return b=arguments[0],c=2<=arguments.length?hb.call(arguments,1):[],db.apply(null,[a,"combineWith",b].concat(hb.call(c),[a.combineAsArray(c).map(function(a){return b.apply(null,a)})]))},a.combineTemplate=function(b){var c,d,e,f,g,h,i,j,k,l;return i=[],l=[],h=function(a){return a[a.length-1]},k=function(a,b,c){return h(a)[b]=c},c=function(a,b){return function(c,d){return k(c,a,d[b])}},g=function(a,b){return function(c){return k(c,a,b)}},j=function(a){return I(a)?[]:{}},e=function(a,b){var d,e;return L(b)?(l.push(b),i.push(c(a,l.length-1))):b!==Object(b)||"function"==typeof b||b instanceof RegExp||b instanceof Date?i.push(g(a,b)):(e=function(a){return function(c){var d;return d=j(b),k(c,a,d),c.push(d)}},d=function(a){return a.pop()},i.push(e(a)),f(b),i.push(d))},f=function(a){return fb.each(a,e)},f(b),d=function(a){var c,d,e,f,g;for(e=j(b),c=[e],f=0,g=i.length;g>f;f++)(d=i[f])(c,a);return e},db(a,"combineTemplate",b,a.combineAsArray(l).map(d))},a.retry=function(b){var c,d,e,f,g,h;if(!K(b.source))throw new l("'source' option has to be a function");return h=b.source,f=b.retries||0,e=b.maxRetries||f,c=b.delay||function(){return 0},d=b.isRetryable||function(){return!0},g=function(b){var g,i;return i={source:h,retries:f-1,maxRetries:e,delay:c,isRetryable:d},g=function(){return a.retry(i)},a.later(c(b)).filter(!1).concat(a.once().flatMap(g))},db(a,"retry",b,h().flatMapError(function(b){return d(b)&&f>0?g({error:b,retriesDone:e-f}):a.once(new i(b))}))},C=0,j=function(){function a(){this.id=++C}return a.prototype.isEvent=function(){return!0},a.prototype.isEnd=function(){return!1},a.prototype.isInitial=function(){return!1},a.prototype.isNext=function(){return!1},a.prototype.isError=function(){return!1},a.prototype.hasValue=function(){return!1},a.prototype.filter=function(){return!0},a.prototype.inspect=function(){return this.toString()},a.prototype.log=function(){return this.toString()},a}(),n=function(a){function b(a){b.__super__.constructor.call(this),this.value=K(a)?fb.cached(a):fb.always(a)}return jb(b,a),b.prototype.isNext=function(){return!0},b.prototype.hasValue=function(){return!0},b.prototype.fmap=function(a){var b;return b=this.value,this.apply(function(){return a(b())})},b.prototype.apply=function(a){return new b(a)},b.prototype.filter=function(a){return a(this.value())},b.prototype.toString=function(){return fb.toString(this.value())},b.prototype.log=function(){return this.value()},b}(j),m=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return jb(b,a),b.prototype.isInitial=function(){return!0},b.prototype.isNext=function(){return!1},b.prototype.apply=function(a){return new b(a)},b.prototype.toNext=function(){return new n(this.value)},b}(n),h=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return jb(b,a),b.prototype.isEnd=function(){return!0},b.prototype.fmap=function(){return this},b.prototype.apply=function(){return this},b.prototype.toString=function(){return"<end>"},b}(j),i=function(a){function b(a){this.error=a}return jb(b,a),b.prototype.isError=function(){return!0},b.prototype.fmap=function(){return this},b.prototype.apply=function(){return this},b.prototype.toString=function(){return"<error> "+fb.toString(this.error)},b}(j),G=0,p=function(){function b(a){this.flatMapError=kb(this.flatMapError,this),this.id=++G,db(a,this),this.initialDesc=this.desc}return b.prototype.subscribe=function(a){return u.wrappedSubscribe(this,a)},b.prototype.onValue=function(){var a;return a=P(arguments),this.subscribe(function(b){return b.hasValue()?a(b.value()):void 0})},b.prototype.onValues=function(a){return this.onValue(function(b){return a.apply(null,b)})},b.prototype.onError=function(){var a;return a=P(arguments),this.subscribe(function(b){return b.isError()?a(b.error):void 0})},b.prototype.onEnd=function(){var a;return a=P(arguments),this.subscribe(function(b){return b.isEnd()?a():void 0})},b.prototype.errors=function(){return db(this,"errors",this.filter(function(){return!1}))},b.prototype.filter=function(){var b,c;return c=arguments[0],b=2<=arguments.length?hb.call(arguments,1):[],z(this,c,b,function(b){return db(this,"filter",b,this.withHandler(function(c){return c.filter(b)?this.push(c):a.more}))})},b.prototype.takeWhile=function(){var b,c;return c=arguments[0],b=2<=arguments.length?hb.call(arguments,1):[],z(this,c,b,function(b){return db(this,"takeWhile",b,this.withHandler(function(c){return c.filter(b)?this.push(c):(this.push(B()),a.noMore)}))})},b.prototype.endOnError=function(){var a,b;return b=arguments[0],a=2<=arguments.length?hb.call(arguments,1):[],null==b&&(b=!0),z(this,b,a,function(a){return db(this,"endOnError",this.withHandler(function(b){return b.isError()&&a(b.error)?(this.push(b),this.push(B())):this.push(b)}))})},b.prototype.take=function(b){return 0>=b?a.never():db(this,"take",b,this.withHandler(function(c){return c.hasValue()?(b--,b>0?this.push(c):(0===b&&this.push(c),this.push(B()),a.noMore)):this.push(c)}))},b.prototype.map=function(){var a,b;return b=arguments[0],a=2<=arguments.length?hb.call(arguments,1):[],b instanceof q?b.sampledBy(this,F):z(this,b,a,function(a){return db(this,"map",a,this.withHandler(function(b){return this.push(b.fmap(a))}))})},b.prototype.mapError=function(){var a;return a=P(arguments),db(this,"mapError",a,this.withHandler(function(b){return this.push(b.isError()?T(a(b.error)):b)}))},b.prototype.mapEnd=function(){var b;return b=P(arguments),db(this,"mapEnd",b,this.withHandler(function(c){return c.isEnd()?(this.push(T(b(c))),this.push(B()),a.noMore):this.push(c)}))},b.prototype.doAction=function(){var a;return a=P(arguments),db(this,"doAction",a,this.withHandler(function(b){return b.hasValue()&&a(b.value()),this.push(b)}))},b.prototype.skip=function(b){return db(this,"skip",b,this.withHandler(function(c){return c.hasValue()&&b>0?(b--,a.more):this.push(c)}))},b.prototype.skipDuplicates=function(a){return null==a&&(a=function(a,b){return a===b}),db(this,"skipDuplicates",this.withStateMachine(o,function(b,c){return c.hasValue()?c.isInitial()||b===o||!a(b.get(),c.value())?[new s(c.value()),[c]]:[b,[]]:[b,[c]]}))},b.prototype.skipErrors=function(){return db(this,"skipErrors",this.withHandler(function(b){return b.isError()?a.more:this.push(b)}))},b.prototype.withStateMachine=function(b,c){var d;return d=b,db(this,"withStateMachine",b,c,this.withHandler(function(b){var e,f,g,h,i,j,k;for(e=c(d,b),f=e[0],h=e[1],d=f,i=a.more,j=0,k=h.length;k>j;j++)if(g=h[j],i=this.push(g),i===a.noMore)return i;return i}))},b.prototype.scan=function(b,c,d){var e,f,g,h;return null==d&&(d={}),f=Z(c),c=d.lazyF?f:function(a,b){return f(a(),b())},e=bb(b).map(function(a){return fb.always(a)}),h=function(b){return function(f){var h,i,j,k;return h=!1,k=U,i=a.more,j=function(){return h?void 0:e.forEach(function(b){return h=!0,i=f(new m(b)),i===a.noMore?(k(),k=U):void 0})},k=b.dispatcher.subscribe(function(b){var g,k;return b.hasValue()?h&&b.isInitial()?a.more:(b.isInitial()||j(),h=!0,k=e.getOrElse(function(){return void 0}),g=fb.cached(function(){return c(k,b.value)}),e=new s(g),d.eager&&g(),f(b.apply(g))):(b.isEnd()&&(i=j()),i!==a.noMore?f(b):void 0)}),u.whenDoneWith(g,j),k}}(this),g=new q(A(this,"scan",b,c),h)},b.prototype.fold=function(a,b,c){return db(this,"fold",a,b,this.scan(a,b,c).sampledBy(this.filter(!1).mapEnd().toProperty()))},b.prototype.zip=function(b,c){return null==c&&(c=Array),db(this,"zip",b,a.zipWith([this,b],c))},b.prototype.diff=function(a,b){return b=Z(b),db(this,"diff",a,b,this.scan([a],function(a,c){return[c,b(a[0],c)]}).filter(function(a){return 2===a.length}).map(function(a){return a[1]}))},b.prototype.flatMap=function(){return E(this,S(arguments))},b.prototype.flatMapFirst=function(){return E(this,S(arguments),!0)},b.prototype.flatMapWithConcurrencyLimit=function(){var a,b;return b=arguments[0],a=2<=arguments.length?hb.call(arguments,1):[],db.apply(null,[this,"flatMapWithConcurrencyLimit",b].concat(hb.call(a),[E(this,S(a),!1,b)]))},b.prototype.flatMapLatest=function(){var a,b;return a=S(arguments),b=this.toEventStream(),db(this,"flatMapLatest",a,b.flatMap(function(c){return R(a(c)).takeUntil(b)}))},b.prototype.flatMapError=function(b){return db(this,"flatMapError",b,this.mapError(function(a){return new i(a)}).flatMap(function(c){return c instanceof i?b(c.error):a.once(c)}))},b.prototype.flatMapConcat=function(){return db.apply(null,[this,"flatMapConcat"].concat(hb.call(arguments),[this.flatMapWithConcurrencyLimit.apply(this,[1].concat(hb.call(arguments)))]))},b.prototype.bufferingThrottle=function(b){return db(this,"bufferingThrottle",b,this.flatMapConcat(function(c){return a.once(c).concat(a.later(b).filter(!1))}))},b.prototype.not=function(){return db(this,"not",this.map(function(a){return!a}))},b.prototype.log=function(){var a;return a=1<=arguments.length?hb.call(arguments,0):[],this.subscribe(function(b){return"undefined"!=typeof console&&null!==console&&"function"==typeof console.log?console.log.apply(console,hb.call(a).concat([b.log()])):void 0}),this},b.prototype.slidingWindow=function(a,b){return null==b&&(b=0),db(this,"slidingWindow",a,b,this.scan([],function(b,c){return b.concat([c]).slice(-a)}).filter(function(a){return a.length>=b}))},b.prototype.combine=function(b,c){var d;return d=Z(c),db(this,"combine",b,c,a.combineAsArray(this,b).map(function(a){return d(a[0],a[1])}))},b.prototype.decode=function(b){return db(this,"decode",b,this.combine(a.combineTemplate(b),function(a,b){return b[a]}))},b.prototype.awaiting=function(b){return db(this,"awaiting",b,a.groupSimultaneous(this,b).map(function(a){var b,c;return b=a[0],c=a[1],0===c.length}).toProperty(!1).skipDuplicates())},b.prototype.name=function(a){return this._name=a,this},b.prototype.withDescription=function(){return A.apply(null,arguments).apply(this)},b.prototype.toString=function(){return this._name?this._name:this.desc.toString()},b.prototype.internalDeps=function(){return this.initialDesc.deps()},b}(),p.prototype.reduce=p.prototype.fold,p.prototype.assign=p.prototype.onValue,p.prototype.inspect=p.prototype.toString,E=function(b,c,e,f){var g,h,i;return i=[b],g=[],h=new k(A(b,"flatMap"+(e?"First":""),c),function(h){var i,j,k,l,n;return k=new d,l=[],n=function(b){var d;return d=R(c(b.value())),g.push(d),k.add(function(b,c){return d.dispatcher.subscribe(function(e){var f;return e.isEnd()?(fb.remove(d,g),j(),i(c),a.noMore):(e instanceof m&&(e=e.toNext()),f=h(e),f===a.noMore&&b(),f)})})},j=function(){var a;return a=l.shift(),a?n(a):void 0},i=function(a){return a(),k.empty()?h(B()):void 0},k.add(function(c,d){return b.dispatcher.subscribe(function(b){return b.isEnd()?i(d):b.isError()?h(b):e&&k.count()>1?a.more:k.unsubscribed?a.noMore:f&&k.count()>f?l.push(b):n(b)})}),k.unsubscribe}),h.internalDeps=function(){return g.length?i.concat(g):i},h},k=function(b){function c(a,b){K(a)&&(b=a,a=[]),c.__super__.constructor.call(this,a),this.dispatcher=new g(b),X(this)}return jb(c,b),c.prototype.delay=function(b){return db(this,"delay",b,this.flatMap(function(c){return a.later(b,c)}))},c.prototype.debounce=function(b){return db(this,"debounce",b,this.flatMapLatest(function(c){return a.later(b,c)}))},c.prototype.debounceImmediate=function(b){return db(this,"debounceImmediate",b,this.flatMapFirst(function(c){return a.once(c).concat(a.later(b).filter(!1))}))},c.prototype.throttle=function(a){return db(this,"throttle",a,this.bufferWithTime(a).map(function(a){return a[a.length-1]}))},c.prototype.bufferWithTime=function(a){return db(this,"bufferWithTime",a,this.bufferWithTimeOrCount(a,Number.MAX_VALUE))},c.prototype.bufferWithCount=function(a){return db(this,"bufferWithCount",a,this.bufferWithTimeOrCount(void 0,a))},c.prototype.bufferWithTimeOrCount=function(a,b){var c;return c=function(c){return c.values.length===b?c.flush():void 0!==a?c.schedule():void 0},db(this,"bufferWithTimeOrCount",a,b,this.buffer(a,c,c))},c.prototype.buffer=function(b,c,d){var e,f,g;return null==c&&(c=U),null==d&&(d=U),e={scheduled:!1,end:void 0,values:[],flush:function(){var b;if(this.scheduled=!1,this.values.length>0){if(b=this.push(T(this.values)),this.values=[],null!=this.end)return this.push(this.end);if(b!==a.noMore)return d(this)}else if(null!=this.end)return this.push(this.end)},schedule:function(){return this.scheduled?void 0:(this.scheduled=!0,b(function(a){return function(){return a.flush()}}(this)))}},g=a.more,K(b)||(f=b,b=function(b){return a.scheduler.setTimeout(b,f)}),db(this,"buffer",this.withHandler(function(a){return e.push=function(a){return function(b){return a.push(b)}}(this),a.isError()?g=this.push(a):a.isEnd()?(e.end=a,e.scheduled||e.flush()):(e.values.push(a.value()),c(e)),g}))},c.prototype.merge=function(b){var c;return c=this,db(c,"merge",b,a.mergeAll(this,b))},c.prototype.toProperty=function(a){return 0===arguments.length&&(a=o),db(this,"toProperty",a,this.scan(a,M,{lazyF:!0}))},c.prototype.toEventStream=function(){return this},c.prototype.sampledBy=function(a,b){return db(this,"sampledBy",a,b,this.toProperty().sampledBy(a,b))},c.prototype.concat=function(a){var b;return b=this,new c(A(b,"concat",a),function(c){var d,e;return e=U,d=b.dispatcher.subscribe(function(b){return b.isEnd()?e=a.dispatcher.subscribe(c):c(b)}),function(){return d(),e()}})},c.prototype.takeUntil=function(b){var c;return c={},db(this,"takeUntil",b,a.groupSimultaneous(this.mapEnd(c),b.skipErrors()).withHandler(function(d){var e,f,g,h,i,j;if(d.hasValue()){if(j=d.value(),e=j[0],b=j[1],b.length)return this.push(B());for(f=a.more,h=0,i=e.length;i>h;h++)g=e[h],f=this.push(g===c?B():T(g));return f}return this.push(d)}))},c.prototype.skipUntil=function(a){var b;return b=a.take(1).map(!0).toProperty(!1),db(this,"skipUntil",a,this.filter(b))},c.prototype.skipWhile=function(){var b,c,d;return c=arguments[0],b=2<=arguments.length?hb.call(arguments,1):[],d=!1,z(this,c,b,function(b){return db(this,"skipWhile",b,this.withHandler(function(c){return!d&&c.hasValue()&&b(c.value())?a.more:(c.hasValue()&&(d=!0),this.push(c))}))})},c.prototype.holdWhen=function(b){var c,d,e;return e=b.startWith(!1),d=e.filter(function(a){return!a}),c=e.filter(fb.id),db(this,"holdWhen",b,this.filter(!1).merge(e.flatMapConcat(function(b){return function(e){return e?b.scan([],function(a,b){return a.concat(b)},{eager:!0}).sampledBy(d).take(1).flatMap(a.fromArray):b.takeUntil(c)}}(this))))},c.prototype.startWith=function(b){return db(this,"startWith",b,a.once(b).concat(this))},c.prototype.withHandler=function(a){var b;return b=new g(this.dispatcher.subscribe,a),new c(A(this,"withHandler",a),b.subscribe)},c}(p),q=function(b){function c(a,b,d){K(a)&&(d=b,b=a,a=[]),c.__super__.constructor.call(this,a),this.dispatcher=new r(this,b,d),X(this)}return jb(c,b),c.prototype.sampledBy=function(b,d){var e,f,g,h,i;return null!=d?d=Z(d):(e=!0,d=function(a){return a()}),i=new t(this,!1,e),g=new t(b,!0,e),h=a.when([i,g],d),f=b instanceof c?h.toProperty():h,db(this,"sampledBy",b,d,f)},c.prototype.sample=function(b){return db(this,"sample",b,this.sampledBy(a.interval(b,{})))},c.prototype.changes=function(){return new k(A(this,"changes"),function(a){return function(b){return a.dispatcher.subscribe(function(a){return a.isInitial()?void 0:b(a)})}}(this))},c.prototype.withHandler=function(a){return new c(A(this,"withHandler",a),this.dispatcher.subscribe,a)},c.prototype.toProperty=function(){return this},c.prototype.toEventStream=function(){return new k(A(this,"toEventStream"),function(a){return function(b){return a.dispatcher.subscribe(function(a){return a.isInitial()&&(a=a.toNext()),b(a)})}}(this))},c.prototype.and=function(a){return db(this,"and",a,this.combine(a,function(a,b){return a&&b}))},c.prototype.or=function(a){return db(this,"or",a,this.combine(a,function(a,b){return a||b}))},c.prototype.delay=function(a){return this.delayChanges("delay",a,function(b){return b.delay(a)})},c.prototype.debounce=function(a){return this.delayChanges("debounce",a,function(b){return b.debounce(a)})},c.prototype.throttle=function(a){return this.delayChanges("throttle",a,function(b){return b.throttle(a)})},c.prototype.delayChanges=function(){var a,b,c;return a=2<=arguments.length?hb.call(arguments,0,c=arguments.length-1):(c=0,[]),b=arguments[c++],db.apply(null,[this].concat(hb.call(a),[v(this,b(this.changes()))]))},c.prototype.takeUntil=function(a){var b;return b=this.changes().takeUntil(a),db(this,"takeUntil",a,v(this,b))},c.prototype.startWith=function(a){return db(this,"startWith",a,this.scan(a,function(a,b){return b}))},c.prototype.bufferingThrottle=function(){var a;return(a=c.__super__.bufferingThrottle.apply(this,arguments)).bufferingThrottle.apply(a,arguments).toProperty()},c}(p),z=function(a,b,c,d){var e;return b instanceof q?(e=b.sampledBy(a,function(a,b){return[a,b]}),d.call(e,function(a){var b,c;return b=a[0],c=a[1],b}).map(function(a){var b,c;return b=a[0],c=a[1]})):(b=O(b,c),d.call(a,b))},v=function(b,c){var d;return d=new k(A(b,"justInitValue"),function(c){var e,f;return f=void 0,e=b.dispatcher.subscribe(function(b){return b.isEnd()||(f=b),a.noMore}),u.whenDoneWith(d,function(){return null!=f&&c(f),c(B())}),e}),d.concat(c).toProperty()},g=function(){function b(a,b){this._subscribe=a,this._handleEvent=b,this.subscribe=kb(this.subscribe,this),this.handleEvent=kb(this.handleEvent,this),this.removeSub=kb(this.removeSub,this),this.subscriptions=[],this.queue=[],this.pushing=!1,this.ended=!1,this.prevError=void 0,this.unsubscribeFromSource=U}return b.prototype.hasSubscribers=function(){return this.subscriptions.length>0},b.prototype.removeSub=function(a){return this.subscriptions=fb.without(a,this.subscriptions)},b.prototype.push=function(a){return u.inTransaction(a,this,this.pushIt,[a])},b.prototype.pushIt=function(b){var c,d,e,f,g,h;if(this.pushing)return this.queue.push(b),a.more;if(b!==this.prevError){b.isError()&&(this.prevError=b),e=!1;try{for(this.pushing=!0,f=this.subscriptions,g=0,h=f.length;h>g;g++)d=f[g],c=d.sink(b),(c===a.noMore||b.isEnd())&&this.removeSub(d);e=!0}finally{this.pushing=!1,e||(this.queue=[])}for(e=!0;this.queue.length;)b=this.queue.shift(),this.push(b);return this.hasSubscribers()?a.more:(this.unsubscribeFromSource(),a.noMore)}},b.prototype.handleEvent=function(a){return a.isEnd()&&(this.ended=!0),this._handleEvent?this._handleEvent(a):this.push(a)},b.prototype.subscribe=function(a){var b,c;return this.ended?(a(B()),U):(b={sink:a},this.subscriptions.push(b),1===this.subscriptions.length&&(c=this._subscribe(this.handleEvent),this.unsubscribeFromSource=function(){return c(),this.unsubscribeFromSource=U}),function(a){return function(){return a.removeSub(b),a.hasSubscribers()?void 0:a.unsubscribeFromSource()}}(this))},b}(),r=function(b){function c(a,b,d){this.property=a,this.subscribe=kb(this.subscribe,this),c.__super__.constructor.call(this,b,d),this.current=o,this.currentValueRootId=void 0,this.propertyEnded=!1}return jb(c,b),c.prototype.push=function(a){return a.isEnd()&&(this.propertyEnded=!0),a.hasValue()&&(this.current=new s(a),this.currentValueRootId=u.currentEventId()),c.__super__.push.call(this,a)},c.prototype.maybeSubSource=function(b,c){return c===a.noMore?U:this.propertyEnded?(b(B()),U):g.prototype.subscribe.call(this,b)},c.prototype.subscribe=function(b){var c,d,e,f;return d=!1,e=a.more,this.current.isDefined&&(this.hasSubscribers()||this.propertyEnded)?(c=u.currentEventId(),f=this.currentValueRootId,!this.propertyEnded&&f&&c&&c!==f?(u.whenDoneWith(this.property,function(a){return function(){return a.currentValueRootId===f?b(H(a.current.get().value())):void 0}}(this)),this.maybeSubSource(b,e)):(u.inTransaction(void 0,this,function(){return e=function(){try{return b(H(this.current.get().value()))}catch(c){return a.more}}.call(this)},[]),this.maybeSubSource(b,e))):this.maybeSubSource(b,e)},c}(g),c=function(b){function c(){this.guardedSink=kb(this.guardedSink,this),this.subscribeAll=kb(this.subscribeAll,this),this.unsubAll=kb(this.unsubAll,this),this.sink=void 0,this.subscriptions=[],this.ended=!1,c.__super__.constructor.call(this,A(a,"Bus"),this.subscribeAll)}return jb(c,b),c.prototype.unsubAll=function(){var a,b,c,d;for(d=this.subscriptions,b=0,c=d.length;c>b;b++)a=d[b],"function"==typeof a.unsub&&a.unsub();return void 0},c.prototype.subscribeAll=function(a){var b,c,d,e;for(this.sink=a,e=w(this.subscriptions),c=0,d=e.length;d>c;c++)b=e[c],this.subscribeInput(b);return this.unsubAll},c.prototype.guardedSink=function(b){return function(c){return function(d){return d.isEnd()?(c.unsubscribeInput(b),a.noMore):c.sink(d)}}(this)},c.prototype.subscribeInput=function(a){return a.unsub=a.input.dispatcher.subscribe(this.guardedSink(a.input))},c.prototype.unsubscribeInput=function(a){var b,c,d,e,f;for(f=this.subscriptions,b=d=0,e=f.length;e>d;b=++d)if(c=f[b],c.input===a)return"function"==typeof c.unsub&&c.unsub(),void this.subscriptions.splice(b,1)},c.prototype.plug=function(a){var b;if(!this.ended)return b={input:a},this.subscriptions.push(b),null!=this.sink&&this.subscribeInput(b),function(b){return function(){return b.unsubscribeInput(a)}}(this)},c.prototype.end=function(){return this.ended=!0,this.unsubAll(),"function"==typeof this.sink?this.sink(B()):void 0},c.prototype.push=function(a){return"function"==typeof this.sink?this.sink(T(a)):void 0},c.prototype.error=function(a){return"function"==typeof this.sink?this.sink(new i(a)):void 0},c}(k),t=function(){function a(a,b,c){this.obs=a,this.sync=b,this.lazy=null!=c?c:!1,this.queue=[]}return a.prototype.subscribe=function(a){return this.obs.dispatcher.subscribe(a)},a.prototype.toString=function(){return this.obs.toString.call(this)},a.prototype.markEnded=function(){return this.ended=!0},a.prototype.consume=function(){return this.lazy?fb.always(this.queue[0]):this.queue[0]},a.prototype.push=function(a){return this.queue=[a]},a.prototype.mayHave=function(){return!0},a.prototype.hasAtLeast=function(){return this.queue.length},a.prototype.flatten=!0,a}(),e=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return jb(b,a),b.prototype.consume=function(){return this.queue.shift()},b.prototype.push=function(a){return this.queue.push(a)},b.prototype.mayHave=function(a){return!this.ended||this.queue.length>=a},b.prototype.hasAtLeast=function(a){return this.queue.length>=a},b.prototype.flatten=!1,b}(t),b=function(a){function b(a){b.__super__.constructor.call(this,a,!0)}return jb(b,a),b.prototype.consume=function(){var a;return a=this.queue,this.queue=[],function(){return a}},b.prototype.push=function(a){return this.queue.push(a())},b.prototype.hasAtLeast=function(){return!0},b}(t),t.isTrigger=function(a){return a instanceof t?a.sync:a instanceof k},t.fromObservable=function(a){return a instanceof t?a:a instanceof q?new t(a,!1):new e(a,!0)},A=function(){var a,b,c;return b=arguments[0],c=arguments[1],a=3<=arguments.length?hb.call(arguments,2):[],(b||c)instanceof f?b||c:new f(b,c,a)},D=function(a){return I(a)?fb.flatMap(D,a):L(a)?[a]:a instanceof t?[a.obs]:[]},f=function(){function a(a,b,c){this.context=a,this.method=b,this.args=c,this.cached=void 0}return a.prototype.deps=function(){return this.cached||(this.cached=D([this.context].concat(this.args)))},a.prototype.apply=function(a){return a.desc=this,a},a.prototype.toString=function(){return fb.toString(this.context)+"."+fb.toString(this.method)+"("+fb.map(fb.toString,this.args)+")"},a}(),db=function(){var a,b,c;return a=2<=arguments.length?hb.call(arguments,0,c=arguments.length-1):(c=0,[]),b=arguments[c++],A.apply(null,a).apply(b)},a.when=function(){var b,c,d,e,f,g,h,i,j,l,m,n,o,p,q,r,s,v,w,z;if(0===arguments.length)return a.never();for(f=arguments.length,q="when: expecting arguments in the form (Observable+,function)+",o=[],j=[],c=0,l=[];f>c;){for(l[c]=arguments[c],l[c+1]=arguments[c+1],i=fb.toArray(arguments[c]),b=arguments[c+1],h={f:K(b)?b:function(){return b},ixs:[]},p=!1,r=0,v=i.length;v>r;r++){for(n=i[r],d=fb.indexOf(o,n),p||(p=t.isTrigger(n)),0>d&&(o.push(n),d=o.length-1),z=h.ixs,s=0,w=z.length;w>s;s++)e=z[s],e.index===d&&e.count++;h.ixs.push({index:d,count:1})}i.length>0&&j.push(h),c+=2}return o.length?(o=fb.map(t.fromObservable,o),g=fb.any(o,function(a){return a.flatten})&&y(fb.map(function(a){return a.obs},o)),m=new k(A.apply(null,[a,"when"].concat(hb.call(l))),function(b){var d,e,f,h,i,k,l;return l=[],f=!1,h=function(a){var b,d,e;for(e=a.ixs,b=0,d=e.length;d>b;b++)if(c=e[b],!o[c.index].hasAtLeast(c.count))return!1;return!0},e=function(a){return!a.sync||a.ended},d=function(a){var b,d,e;for(e=a.ixs,b=0,d=e.length;d>b;b++)if(c=e[b],!o[c.index].mayHave(c.count))return!0},i=function(a){return!a.source.flatten},k=function(k){return function(n){var p,q,r;return q=function(){return u.whenDoneWith(m,p)},r=function(){var d,e,f,g,k,m;if(!(l.length>0))return a.more;for(f=a.more,g=l.pop(),k=0,m=j.length;m>k;k++)if(e=j[k],h(e))return d=function(){var a,b,d,f;for(d=e.ixs,f=[],a=0,b=d.length;b>a;a++)c=d[a],f.push(o[c.index].consume());return f}(),f=b(g.e.apply(function(){var a,b;return b=function(){var b,c,e;for(e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a());return e}(),e.f.apply(e,b)})),l.length&&(l=fb.filter(i,l)),f===a.noMore?f:r()},p=function(){var c;return c=r(),f&&(f=!1,(fb.all(o,e)||fb.all(j,d))&&(c=a.noMore,b(B()))),c===a.noMore&&n(),c},k.subscribe(function(c){var d;return c.isEnd()?(f=!0,k.markEnded(),q()):c.isError()?d=b(c):(k.push(c.value),k.sync&&(l.push({source:k,e:c}),g||u.hasWaiters()?q():p())),d===a.noMore&&n(),d||a.more})}},x.apply(null,function(){var a,b,c;for(c=[],a=0,b=o.length;b>a;a++)n=o[a],c.push(k(n));return c}())})):a.never()},y=function(a,b){var c;return null==b&&(b=[]),c=function(a){var d;return fb.contains(b,a)?!0:(d=a.internalDeps(),d.length?(b.push(a),fb.any(d,c)):(b.push(a),!1))},fb.any(a,c)},a.update=function(){var b,c,d,e;for(c=arguments[0],e=2<=arguments.length?hb.call(arguments,1):[],d=function(a){return function(){var b;return b=1<=arguments.length?hb.call(arguments,0):[],function(c){return a.apply(null,[c].concat(b)) | ||
}}},b=e.length-1;b>0;)e[b]instanceof Function||(e[b]=function(a){return function(){return a}}(e[b])),e[b]=d(e[b]),b-=2;return db.apply(null,[a,"update",c].concat(hb.call(e),[a.when.apply(a,e).scan(c,function(a,b){return b(a)})]))},x=function(){var a;return a=1<=arguments.length?hb.call(arguments,0):[],new d(a).unsubscribe},d=function(){function a(a){var b,c,d;for(null==a&&(a=[]),this.unsubscribe=kb(this.unsubscribe,this),this.unsubscribed=!1,this.subscriptions=[],this.starting=[],c=0,d=a.length;d>c;c++)b=a[c],this.add(b)}return a.prototype.add=function(a){var b,c,d;if(!this.unsubscribed)return b=!1,c=U,this.starting.push(a),d=function(d){return function(){return d.unsubscribed?void 0:(b=!0,d.remove(c),fb.remove(a,d.starting))}}(this),c=a(this.unsubscribe,d),this.unsubscribed||b||this.subscriptions.push(c),fb.remove(a,this.starting),c},a.prototype.remove=function(a){return this.unsubscribed?void 0:void 0!==fb.remove(a,this.subscriptions)?a():void 0},a.prototype.unsubscribe=function(){var a,b,c,d;if(!this.unsubscribed){for(this.unsubscribed=!0,d=this.subscriptions,b=0,c=d.length;c>b;b++)(a=d[b])();return this.subscriptions=[],this.starting=[]}},a.prototype.count=function(){return this.unsubscribed?0:this.subscriptions.length+this.starting.length},a.prototype.empty=function(){return 0===this.count()},a}(),a.CompositeUnsubscribe=d,s=function(){function a(a){this.value=a}return a.prototype.getOrElse=function(){return this.value},a.prototype.get=function(){return this.value},a.prototype.filter=function(b){return b(this.value)?new a(this.value):o},a.prototype.map=function(b){return new a(b(this.value))},a.prototype.forEach=function(a){return a(this.value)},a.prototype.isDefined=!0,a.prototype.toArray=function(){return[this.value]},a.prototype.inspect=function(){return"Some("+this.value+")"},a.prototype.toString=function(){return this.inspect()},a}(),o={getOrElse:function(a){return a},filter:function(){return o},map:function(){return o},forEach:function(){},isDefined:!1,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}},u=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n;return j=void 0,k=[],l={},c=[],b=function(a){return j?c.push(a):a()},m=function(a,b){var c;return j?(c=l[a.id],null==c?(c=l[a.id]=[b],k.push(a)):c.push(b)):b()},e=function(){for(;k.length>0;)g(0);return void 0},g=function(a){var b,c,d,e,g,h;for(c=k[a],d=c.id,e=l[d],k.splice(a,1),delete l[d],f(c),g=0,h=e.length;h>g;g++)(b=e[g])();return void 0},f=function(a){var b,c,d,e,h;for(c=a.internalDeps(),e=0,h=c.length;h>e;e++)b=c[e],f(b),l[b.id]&&(d=fb.indexOf(k,b),g(d));return void 0},i=function(a,b,d,f){var g,h,i,k;if(j)return d.apply(b,f);for(j=a,g=d.apply(b,f),e(),j=void 0;c.length;)for(h=c,c=[],i=0,k=h.length;k>i;i++)(d=h[i])();return g},d=function(){return j?j.id:void 0},n=function(c,d){var e,f,g;return g=!1,e=function(){},f=function(){return g=!0,e()},e=c.dispatcher.subscribe(function(c){return b(function(){var b;return g||(b=d(c),b!==a.noMore)?void 0:f()})}),f},h=function(){return k.length>0},{whenDoneWith:m,hasWaiters:h,inTransaction:i,currentEventId:d,wrappedSubscribe:n}}(),a.EventStream=k,a.Property=q,a.Observable=p,a.Bus=c,a.Initial=m,a.Next=n,a.End=h,a.Error=i,U=function(){},M=function(a,b){return b()},F=function(a){return a},H=function(a){return new m(fb.always(a))},T=function(a){return new n(fb.always(a))},B=function(){return new h},$=function(a){return a instanceof j?a:T(a)},w=function(a){return a.slice(0)},K=function(a){return"function"==typeof a},I=function(a){return a instanceof Array},L=function(a){return a instanceof p},V=function(a,b){return function(){var c;return c=1<=arguments.length?hb.call(arguments,0):[],a.apply(null,b.concat(c))}},S=function(a){return 1===a.length&&L(a[0])?fb.always(a[0]):P(a)},P=function(a){return a=Array.prototype.slice.call(a),Q.apply(null,a)},Q=eb(function(){var a,b;return b=arguments[0],a=2<=arguments.length?hb.call(arguments,1):[],K(b)?a.length?V(b,a):b:J(b)?_(b,a):fb.always(b)}),O=function(a,b){return Q.apply(null,[a].concat(hb.call(b)))},R=function(b){return L(b)?b:a.once(b)},J=function(a){return"string"==typeof a&&a.length>1&&"."===a.charAt(0)},a.isFieldKey=J,_=function(a,b){var c,d;return d=a.slice(1).split("."),c=fb.map(cb(b),d),function(b){var d,e;for(d=0,e=c.length;e>d;d++)a=c[d],b=a(b);return b}},cb=function(a){return function(b){return function(c){var d;return null==c?void 0:(d=c[b],K(d)?d.apply(c,a):d)}}},ab=function(a){return a.slice(1)},Z=function(a){var b;return K(a)?a:J(a)?(b=ab(a),function(a,c){return a[b](c)}):void 0},bb=function(a){return a instanceof s||a===o?a:new s(a)},fb={indexOf:Array.prototype.indexOf?function(a,b){return a.indexOf(b)}:function(a,b){var c,d,e,f;for(c=e=0,f=a.length;f>e;c=++e)if(d=a[c],b===d)return c;return-1},indexWhere:function(a,b){var c,d,e,f;for(c=e=0,f=a.length;f>e;c=++e)if(d=a[c],b(d))return c;return-1},head:function(a){return a[0]},always:function(a){return function(){return a}},negate:function(a){return function(b){return!a(b)}},empty:function(a){return 0===a.length},tail:function(a){return a.slice(1,a.length)},filter:function(a,b){var c,d,e,f;for(c=[],e=0,f=b.length;f>e;e++)d=b[e],a(d)&&c.push(d);return c},map:function(a,b){var c,d,e,f;for(f=[],d=0,e=b.length;e>d;d++)c=b[d],f.push(a(c));return f},each:function(a,b){var c,d;for(c in a)d=a[c],b(c,d);return void 0},toArray:function(a){return I(a)?a:[a]},contains:function(a,b){return-1!==fb.indexOf(a,b)},id:function(a){return a},last:function(a){return a[a.length-1]},all:function(a,b){var c,d,e;for(null==b&&(b=fb.id),d=0,e=a.length;e>d;d++)if(c=a[d],!b(c))return!1;return!0},any:function(a,b){var c,d,e;for(null==b&&(b=fb.id),d=0,e=a.length;e>d;d++)if(c=a[d],b(c))return!0;return!1},without:function(a,b){return fb.filter(function(b){return b!==a},b)},remove:function(a,b){var c;return c=fb.indexOf(b,a),c>=0?b.splice(c,1):void 0},fold:function(a,b,c){var d,e,f;for(e=0,f=a.length;f>e;e++)d=a[e],b=c(b,d);return b},flatMap:function(a,b){return fb.fold(b,[],function(b,c){return b.concat(a(c))})},cached:function(a){var b;return b=o,function(){return b===o&&(b=a(),a=void 0),b}},toString:function(a){var b,c,d,e;try{return W++,null==a?"undefined":K(a)?"function":I(a)?W>5?"[..]":"["+fb.map(fb.toString,a).toString()+"]":null!=(null!=a?a.toString:void 0)&&a.toString!==Object.prototype.toString?a.toString():"object"==typeof a?W>5?"{..}":(c=function(){var c;c=[];for(d in a)ib.call(a,d)&&(e=function(){try{return a[d]}catch(c){return b=c}}(),c.push(fb.toString(d)+":"+fb.toString(e)));return c}(),"{"+c+"}"):a}finally{W--}}},W=0,a._=fb,a.scheduler={setTimeout:function(a,b){return setTimeout(a,b)},setInterval:function(a,b){return setInterval(a,b)},clearInterval:function(a){return clearInterval(a)},now:function(){return(new Date).getTime()}},"undefined"!=typeof define&&null!==define&&null!=define.amd?(define([],function(){return a}),this.Bacon=a):"undefined"!=typeof module&&null!==module&&null!=module.exports?(module.exports=a,a.Bacon=a):this.Bacon=a}).call(this); |
{ | ||
"name": "baconjs", | ||
"description": "A small functional reactive programming lib for JavaScript.", | ||
"version": "0.7.27", | ||
"version": "0.7.28", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "bacon.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
433315
9844