Comparing version 0.5.1 to 0.6.0
{ | ||
"name": "bacon", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"main": "dist/Bacon.js" | ||
} |
{ | ||
"name": "bacon", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"main": "dist/Bacon.js", | ||
@@ -5,0 +5,0 @@ "repo": "raimohanska/bacon.js", |
@@ -1,1 +0,1 @@ | ||
!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=[].slice,T={}.hasOwnProperty,U=function(a,b){function c(){this.constructor=a}for(var d in b)T.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},V=function(a,b){return function(){return a.apply(b,arguments)}};"undefined"!=typeof module&&null!==module?(module.exports=a={},a.Bacon=a):("function"==typeof require&&null!=require.amd&&define("bacon",[],function(){return a}),this.Bacon=a={}),a.fromBinder=function(b,c){return null==c&&(c=O.id),new h(function(d){var e;return e=b(function(){var b,f,h,i,j,k,l;for(b=1<=arguments.length?S.call(arguments,0):[],i=c.apply(null,b),i instanceof Array&&O.last(i)instanceof g||(i=[i]),l=[],j=0,k=i.length;k>j;j++)f=i[j],h=d(f=J(f)),h===a.noMore||f.isEnd()?null!=e?l.push(e()):l.push(a.scheduler.setTimeout(function(){return e()},0)):l.push(void 0);return l})})},a.$={asEventStream:function(b,c,d){var e,f=this;return y(c)&&(e=[c,null],d=e[0],c=e[1]),a.fromBinder(function(a){return f.on(b,c,a),function(){return f.off(b,c,a)}},d)}},null!=(P="undefined"!=typeof jQuery&&null!==jQuery?jQuery:"undefined"!=typeof Zepto&&null!==Zepto?Zepto:null)&&(P.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,a.fromBinder(function(a){return e.call(b,c,a),function(){return f.call(b,c,a)}},d)},a.fromPromise=function(b,c){return a.fromBinder(function(a){return b.then(a,function(b){return a(new f(b))}),function(){return c?"function"==typeof b.abort?b.abort():void 0:void 0}},function(a){return[a,t()]})},a.noMore=["<no-more>"],a.more=["<more>"],a.later=function(b,c){return a.sequentially(b,[c])},a.sequentially=function(b,c){var d;return d=0,a.fromPoll(b,function(){var a;return a=c[d++],d<c.length?a:d===c.length?[a,t()]:t()})},a.repeatedly=function(b,c){var d;return d=0,a.fromPoll(b,function(){return c[d++%c.length]})},A=function(b){return function(){var c,d,e;return d=arguments[0],c=2<=arguments.length?S.call(arguments,1):[],e=G(b,[function(a,b){return d.apply(null,S.call(a).concat([b]))}]),a.combineAsArray(c).flatMap(e)}},a.fromCallback=A(function(){var b,c;return c=arguments[0],b=2<=arguments.length?S.call(arguments,1):[],a.fromBinder(function(a){return B(c,b)(a),F},function(a){return[a,t()]})}),a.fromNodeCallback=A(function(){var b,c;return c=arguments[0],b=2<=arguments.length?S.call(arguments,1):[],a.fromBinder(function(a){return B(c,b)(a),F},function(a,b){return a?[new f(a),t()]:[b,t()]})}),a.fromPoll=function(b,c){return 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={}),a.fromPoll(b,function(){return E(c)})},a.constant=function(a){return new m(H([a],w),!0)},a.never=function(){return a.fromArray([])},a.once=function(b){return a.fromArray([b])},a.fromArray=function(a){return new h(H(a,J))},H=function(a,b){return function(c){var d,e,f;for(e=0,f=a.length;f>e;e++)d=a[e],c(b(d));return c(t()),F}},a.mergeAll=function(){var b,c;return c=arguments[0],b=2<=arguments.length?S.call(arguments,1):[],c instanceof Array||(c=[c].concat(b)),O.fold(c,a.never(),function(a,b){return a.merge(b)})},a.zipAsArray=function(){var b,c;return c=arguments[0],b=2<=arguments.length?S.call(arguments,1):[],c instanceof Array||(c=[c].concat(b)),a.zipWith(c,Array)},a.zipWith=function(){var b,c,d,e;return d=arguments[0],b=arguments[1],c=3<=arguments.length?S.call(arguments,2):[],y(d)&&(e=[[b].concat(c),d],d=e[0],b=e[1]),a.when(d,b)},a.combineAsArray=function(){var b,c,d,e;return d=arguments[0],b=2<=arguments.length?S.call(arguments,1):[],d instanceof Array||(d=[d].concat(b)),d.length?(e=function(){var a,b,e;for(e=[],a=0,b=d.length;b>a;a++)c=d[a],e.push(k);return e}(),new m(function(b){var f,g,h,i,j,k,m,n,o,q,r,s;for(q=!1,o=function(){var a,b,e;for(e=[],a=0,b=d.length;b>a;a++)c=d[a],e.push(F);return e}(),n=function(){var a,b,c;for(b=0,c=o.length;c>b;b++)a=o[b],a();return q=!0},h=function(){var a,b,e;for(e=[],a=0,b=d.length;b>a;a++)c=d[a],e.push(!1);return e}(),f=function(){var c;return O.all(h)?(c=b(t()),c===a.noMore&&n(),c):void 0},j=!1,g=function(c,d){return function(g){var h,i;return g.isEnd()?(c(),f(),a.noMore):g.isError()?(h=b(g),h===a.noMore&&n(),h):(d(g.value),O.all(O.map(function(a){return a.isDefined},e))?j&&g.isInitial()?a.more:(j=!0,i=function(){var a,b,c,d;for(d=[],b=0,c=e.length;c>b;b++)a=e[b],d.push(a.get()());return d},h=b(g.apply(i)),h===a.noMore&&n(),h):a.more)}},k=function(a){return g(function(){return h[a]=!0},function(b){return e[a]=new p(b)})},i=r=0,s=d.length;s>r;i=++r)m=d[i],m instanceof l||(m=a.constant(m)),q||(o[i]=m.subscribeInternal(k(i)));return n})):a.constant([])},a.onValues=function(){var b,c,d;return c=2<=arguments.length?S.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?S.call(arguments,1):[],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,m;return i=[],m=[],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 a instanceof Array?[]:{}},e=function(a,b){var d,e;return b instanceof l?(m.push(b),i.push(c(a,m.length-1))):b===Object(b)&&"function"!=typeof 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)):i.push(g(a,b))},f=function(a){return O.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],d(c,a);return e},a.combineAsArray(m).map(d)},g=function(){function a(){}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.onDone=function(a){return a()},a}(),j=function(a){function b(a){var b=this;this.value=y(a)?function(){var c;return c=a(),b.value=O.always(c),c}:O.always(a)}return U(b,a),b.prototype.isNext=function(){return!0},b.prototype.hasValue=function(){return!0},b.prototype.fmap=function(a){var b=this;return this.apply(function(){return a(b.value())})},b.prototype.apply=function(a){return new b(a)},b.prototype.filter=function(a){return a(this.value())},b.prototype.describe=function(){return this.value()},b}(g),i=function(a){function b(){return Q=b.__super__.constructor.apply(this,arguments)}return U(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 j(this.value)},b}(j),e=function(a){function b(){return R=b.__super__.constructor.apply(this,arguments)}return U(b,a),b.prototype.isEnd=function(){return!0},b.prototype.fmap=function(){return this},b.prototype.apply=function(){return this},b.prototype.describe=function(){return"<end>"},b}(g),f=function(a){function b(a){this.error=a}return U(b,a),b.prototype.isError=function(){return!0},b.prototype.fmap=function(){return this},b.prototype.apply=function(){return this},b.prototype.describe=function(){return"<error> "+this.error},b}(g),l=function(){function b(){this.combine=V(this.combine,this),this.flatMapLatest=V(this.flatMapLatest,this),this.fold=V(this.fold,this),this.scan=V(this.scan,this),this.takeUntil=V(this.takeUntil,this),this.assign=this.onValue}return b.prototype.onValue=function(){var a,b;return b=arguments[0],a=2<=arguments.length?S.call(arguments,1):[],b=B(b,a),this.subscribe(function(a){return a.hasValue()?b(a.value()):void 0})},b.prototype.onValues=function(a){return this.onValue(function(b){return a.apply(null,b)})},b.prototype.onError=function(){var a,b;return b=arguments[0],a=2<=arguments.length?S.call(arguments,1):[],b=B(b,a),this.subscribe(function(a){return a.isError()?b(a.error):void 0})},b.prototype.onEnd=function(){var a,b;return b=arguments[0],a=2<=arguments.length?S.call(arguments,1):[],b=B(b,a),this.subscribe(function(a){return a.isEnd()?b():void 0})},b.prototype.errors=function(){return this.filter(function(){return!1})},b.prototype.filter=function(){var b,c;return c=arguments[0],b=2<=arguments.length?S.call(arguments,1):[],c instanceof m?c.sampledBy(this,function(a,b){return[a,b]}).filter(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]}):(c=B(c,b),this.withHandler(function(b){return b.filter(c)?this.push(b):a.more}))},b.prototype.takeWhile=function(){var b,c;return c=arguments[0],b=2<=arguments.length?S.call(arguments,1):[],c=B(c,b),this.withHandler(function(b){return b.filter(c)?this.push(b):(this.push(t()),a.noMore)})},b.prototype.endOnError=function(){return this.withHandler(function(a){return a.isError()?(this.push(a),this.push(t())):this.push(a)})},b.prototype.take=function(b){return 0>=b?a.never():this.withHandler(function(c){return c.hasValue()?(b--,b>0?this.push(c):(0===b&&this.push(c),this.push(t()),a.noMore)):this.push(c)})},b.prototype.map=function(){var a,b;return b=arguments[0],a=2<=arguments.length?S.call(arguments,1):[],b=B(b,a),this.withHandler(function(a){return this.push(a.fmap(b))})},b.prototype.mapError=function(){var a,b;return b=arguments[0],a=2<=arguments.length?S.call(arguments,1):[],b=B(b,a),this.withHandler(function(a){return a.isError()?this.push(E(b(a.error))):this.push(a)})},b.prototype.mapEnd=function(){var b,c;return c=arguments[0],b=2<=arguments.length?S.call(arguments,1):[],c=B(c,b),this.withHandler(function(b){return b.isEnd()?(this.push(E(c(b))),this.push(t()),a.noMore):this.push(b)})},b.prototype.doAction=function(){var a,b;return b=arguments[0],a=2<=arguments.length?S.call(arguments,1):[],b=B(b,a),this.withHandler(function(a){return a.hasValue()&&b(a.value()),this.push(a)})},b.prototype.takeUntil=function(b){var c;return c=this,this.withSubscribe(function(d){var e,f,g,h,i,j;return j=!1,h=F,i=F,g=function(){return h(),i(),j=!0},e=function(b){return b.isEnd()?(i(),d(b),a.noMore):(b.onDone(function(){var c;return j||(c=d(b),c!==a.noMore)?void 0:g()}),a.more)},f=function(b){return b.isError()?a.more:b.isEnd()?a.noMore:(h(),d(t()),a.noMore)},h=c.subscribe(e),j||(i=b.subscribe(f)),g})},b.prototype.skip=function(b){return this.withHandler(function(c){return c.hasValue()?b>0?(b--,a.more):this.push(c):this.push(c)})},b.prototype.skipDuplicates=function(a){return null==a&&(a=function(a,b){return a===b}),this.withStateMachine(k,function(b,c){return c.hasValue()?b!==k&&a(b.get(),c.value())?[b,[]]:[new p(c.value()),[c]]:[b,[c]]})},b.prototype.withStateMachine=function(b,c){var d;return d=b,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){var d,e,f=this;return c=I(c),d=M(b),e=function(b){var e,g,h,i;return e=!1,i=F,g=a.more,h=function(){return e?void 0:(e=!0,d.forEach(function(c){return g=b(w(c)),g===a.noMore?(i(),i=F):void 0}))},i=f.subscribe(function(f){return f.hasValue()?e&&f.isInitial()?a.more:(e=!0,d=new p(c(d.getOrElse(void 0),f.value())),b(f.apply(O.always(d.get())))):(f.isEnd()&&(g=h()),g!==a.noMore?b(f):void 0)}),h(),i},new m(e)},b.prototype.fold=function(a,b){return this.scan(a,b).sampledBy(this.filter(!1).mapEnd().toProperty())},b.prototype.zip=function(b,c){return null==c&&(c=Array),a.zipWith([this,b],c)},b.prototype.diff=function(a,b){return b=I(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(c,d){var e;return c=C(c),e=this,new h(function(f){var g,h,j,k,l,m;return h=[],j=!1,m=function(){},l=function(){var a,b,c;for(m(),b=0,c=h.length;c>b;b++)a=h[b],a();return h=[]},g=function(){return j&&0===h.length?f(t()):void 0},k=function(e){var k,m,n,o,p;return e.isEnd()?(j=!0,g()):e.isError()?f(e):d&&h.length?a.more:(k=c(e.value()),k instanceof b||(k=a.once(k)),p=void 0,m=!1,o=function(){return null!=p&&O.remove(p,h),g()},n=function(b){var c;return b.isEnd()?(o(),m=!0,a.noMore):(b instanceof i&&(b=b.toNext()),c=f(b),c===a.noMore&&l(),c)},p=k.subscribe(n),m?void 0:h.push(p))},m=e.subscribe(k),l})},b.prototype.flatMapFirst=function(a){return this.flatMap(a,!0)},b.prototype.flatMapLatest=function(a){var b;return a=C(a),b=this.toEventStream(),b.flatMap(function(c){return a(c).takeUntil(b)})},b.prototype.not=function(){return this.map(function(a){return!a})},b.prototype.log=function(){var a;return a=1<=arguments.length?S.call(arguments,0):[],this.subscribe(function(b){return"undefined"!=typeof console&&null!==console?"function"==typeof console.log?console.log.apply(console,S.call(a).concat([b.describe()])):void 0:void 0}),this},b.prototype.slidingWindow=function(a,b){return null==b&&(b=0),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=I(c),a.combineAsArray(this,b).map(function(a){return d(a[0],a[1])})},b.prototype.decode=function(b){return this.combine(a.combineTemplate(b),function(a,b){return b[a]})},b}(),l.prototype.reduce=l.prototype.fold,h=function(b){function c(a){var b;c.__super__.constructor.call(this),b=new d(a),this.subscribe=b.subscribe,this.subscribeInternal=this.subscribe,this.hasSubscribers=b.hasSubscribers}return U(c,b),c.prototype.map=function(){var a,b;return b=arguments[0],a=2<=arguments.length?S.call(arguments,1):[],b instanceof m?b.sampledBy(this,u):c.__super__.map.apply(this,[b].concat(S.call(a)))},c.prototype.delay=function(b){return this.flatMap(function(c){return a.later(b,c)})},c.prototype.debounce=function(b){return this.flatMapLatest(function(c){return a.later(b,c)})},c.prototype.debounceImmediate=function(b){return this.flatMapFirst(function(c){return a.once(c).concat(a.later(b).filter(!1))})},c.prototype.throttle=function(a){return this.bufferWithTime(a).map(function(a){return a[a.length-1]})},c.prototype.bufferWithTime=function(a){return this.bufferWithTimeOrCount(a,Number.MAX_VALUE)},c.prototype.bufferWithCount=function(a){return 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},this.buffer(a,c,c)},c.prototype.buffer=function(b,c,d){var e,f,g;return null==c&&(c=function(){}),null==d&&(d=function(){}),e={scheduled:!1,end:null,values:[],flush:function(){var b;if(this.scheduled=!1,this.values.length>0){if(b=this.push(E(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(){var a=this;return this.scheduled?void 0:(this.scheduled=!0,b(function(){return a.flush()}))}},g=a.more,y(b)||(f=b,b=function(b){return a.scheduler.setTimeout(b,f)}),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 d;return d=this,new c(function(c){var e,f,g,h,i,j;return h=F,i=F,j=!1,g=function(){return h(),i(),j=!0},e=0,f=function(b){var d;return b.isEnd()?(e++,2===e?c(t()):a.more):(d=c(b),d===a.noMore&&g(),d)},h=d.subscribe(f),j||(i=b.subscribe(f)),g})},c.prototype.toProperty=function(a){return 0===arguments.length&&(a=k),this.scan(a,z)},c.prototype.toEventStream=function(){return this},c.prototype.concat=function(a){var b;return b=this,new c(function(c){var d;return d=b.subscribe(function(b){return b.isEnd()?d=a.subscribe(c):c(b)}),function(){return d()}})},c.prototype.skipUntil=function(a){return a.take(1).flatMap(this)},c.prototype.awaiting=function(a){return this.map(!0).merge(a.map(!1)).toProperty(!1)},c.prototype.startWith=function(b){return a.once(b).concat(this)},c.prototype.withHandler=function(a){var b;return b=new d(this.subscribe,a),new c(b.subscribe)},c.prototype.withSubscribe=function(a){return new c(a)},c}(l),m=function(b){function c(b,d){this.toEventStream=V(this.toEventStream,this),this.toProperty=V(this.toProperty,this),this.changes=V(this.changes,this),this.sample=V(this.sample,this);var e=this;c.__super__.constructor.call(this),this.subscribeInternal=d===!0?b:new n(b,d).subscribe,this.sampledBy=function(a,d){var f,g;return f=null!=d?(d=I(d),function(a,b){return d(a.value(),b.value())}):function(a){return a.value()},g=k,b=function(b){var c,d,h,i;return i=!1,d=F,h=F,c=function(){return d(),h(),i=!0},d=e.subscribeInternal(function(a){return a.hasValue()?g=new p(a):a.isError()?b(a):void 0}),h=a.subscribe(function(a){return a.hasValue()?g.forEach(function(c){return b(a.apply(f(c,a)))}):(a.isEnd()&&d(),b(a))}),c},a instanceof c?new c(b):new h(b)},this.subscribe=function(b){var c,d,f,g,h;return f=a.more,c=function(){function c(){}return c.prototype.set=function(a){return this.event=a},c.prototype.send=function(){var c;return c=this.event,this.event=null,null!=c&&f!==a.noMore&&(f=b(c),f===a.noMore)?g():void 0},c}(),h=new c,d=new c,g=F,g=e.subscribeInternal(function(c){return c.isError()?f!==a.noMore&&(f=b(c)):(c.hasValue()?h.set(c):c.isEnd()&&d.set(c),o.onDone(function(){return h.send(),d.send()})),f}),function(){return f=a.noMore,g()}}}return U(c,b),c.prototype.sample=function(b){return this.sampledBy(a.interval(b,{}))},c.prototype.changes=function(){var a=this;return new h(function(b){return a.subscribe(function(a){return a.isInitial()?void 0:b(a)})})},c.prototype.withHandler=function(a){return new c(this.subscribeInternal,a)},c.prototype.withSubscribe=function(a){return new c(a)},c.prototype.toProperty=function(){return this},c.prototype.toEventStream=function(){var a=this;return new h(function(b){return a.subscribe(function(a){return a.isInitial()&&(a=a.toNext()),b(a)})})},c.prototype.and=function(a){return this.combine(a,function(a,b){return a&&b})},c.prototype.or=function(a){return this.combine(a,function(a,b){return a||b})},c.prototype.delay=function(a){return this.delayChanges(function(b){return b.delay(a)})},c.prototype.debounce=function(a){return this.delayChanges(function(b){return b.debounce(a)})},c.prototype.throttle=function(a){return this.delayChanges(function(b){return b.throttle(a)})},c.prototype.delayChanges=function(a){return q(this,a(this.changes()))},c}(l),q=function(b,c){var d;return d=function(b){var c;return c=k,b.subscribe(function(b){return b.hasValue()&&(c=new p(b.value())),a.noMore}),c},c.toProperty(d(b))},d=function(){function b(b,c){var d,e,f,h,i,j,k,l,m,n,o=this;null==b&&(b=function(){return F}),l=[],j=null,i=!1,f=!1,this.hasSubscribers=function(){return l.length>0},h=null,m=F,k=function(a){return l=O.without(a,l)},n=null,e=function(a){var b,c,d,e;if(null!=n)for(c=n,n=null,d=0,e=c.length;e>d;d++)b=c[d],b();return a.onDone=g.prototype.onDone},d=function(a){return n=(n||[]).concat([a])},this.push=function(b){var c,f,g,m,n,p;if(i)return j=(j||[]).concat([b]),a.more;if(b!==h){b.isError()&&(h=b),g=!1;try{for(i=!0,b.onDone=d,m=l,n=0,p=m.length;p>n;n++)f=m[n],c=f.sink(b),(c===a.noMore||b.isEnd())&&k(f);g=!0}finally{i=!1,g||(j=null)}for(g=!0;null!=j?j.length:void 0;)b=O.head(j),j=O.tail(j),o.push(b);return e(b),o.hasSubscribers()?a.more:a.noMore}},null==c&&(c=function(a){return this.push(a)}),this.handleEvent=function(a){return a.isEnd()&&(f=!0),c.apply(o,[a])},this.subscribe=function(a){var c;return f?(a(t()),F):(c={sink:a},l=l.concat(c),1===l.length&&(m=b(o.handleEvent)),function(){return k(c),o.hasSubscribers()?void 0:m()})}}return b}(),n=function(b){function c(b,d){var e,f,g,h=this;c.__super__.constructor.call(this,b,d),e=k,g=this.push,b=this.subscribe,f=!1,this.push=function(a){return a.isEnd()&&(f=!0),a.hasValue()&&(e=new p(a.value())),o.inTransaction(function(){return g.apply(h,[a])})},this.subscribe=function(c){var d,g,i;return d=!1,i=function(){return h.hasSubscribers()||f},g=e.filter(i).map(function(a){return c(w(a))}),g.getOrElse(a.more)===a.noMore?F:f?(c(t()),F):b.apply(h,[c])}}return U(c,b),c}(d),o=function(){var a,b,c,d;return d=[],c=!1,b=function(a){return c?d.push(a):a()},a=function(a){var b,e,f,g,h;if(c)return a();c=!0;try{a()}finally{c=!1}for(e=d,d=[],h=[],f=0,g=e.length;g>f;f++)b=e[f],h.push(b());return h},{onDone:b,inTransaction:a}}(),b=function(b){function c(){var b,d,e,g,h,i,j,k;e=void 0,i=[],b=!1,d=function(b){return function(c){return c.isEnd()?(k(b),a.noMore):e(c)}},j=function(){var a,b,c,d;for(d=[],b=0,c=i.length;c>b;b++)a=i[b],d.push("function"==typeof a.unsub?a.unsub():void 0);return d},h=function(a){return a.unsub=a.input.subscribe(d(a.input))},k=function(a){var b,c,d,e;for(b=d=0,e=i.length;e>d;b=++d)if(c=i[b],c.input===a)return"function"==typeof c.unsub&&c.unsub(),i.splice(b,1),void 0},g=function(a){var b,c,d,f,g;for(e=a,c=[],g=r(i),d=0,f=g.length;f>d;d++)b=g[d],h(b);return j},c.__super__.constructor.call(this,g),this.plug=function(a){var c;if(!b)return c={input:a},i.push(c),null!=e&&h(c),function(){return k(a)}},this.push=function(a){return"function"==typeof e?e(E(a)):void 0},this.error=function(a){return"function"==typeof e?e(new f(a)):void 0},this.end=function(){return b=!0,j(),"function"==typeof e?e(t()):void 0}}return U(c,b),c}(h),a.when=function(){var b,c,d,e,f,g,i,j,k,l,n,o,p,q,r,u,v,w;if(l=1<=arguments.length?S.call(arguments,0):[],0===l.length)return a.never();for(g=l.length,p="when: expecting arguments in the form (Observable+,function)+",o=[],k=[],d=0;g>d;){for(j=O.toArray(l[d]),c=l[d+1],i={f:y(c)?c:function(){return c},ixs:[]},q=0,u=j.length;u>q;q++){for(n=j[q],e=o.indexOf(n),0>e&&(o.push(n),e=o.length-1),w=i.ixs,r=0,v=w.length;v>r;r++)f=w[r],f.index===e&&f.count++;i.ixs.push({index:e,count:1})}k.push(i),d+=2}return b=function(){function a(a){var b,c;c=[],b=!1,this.subscribe=a.subscribe,this.markEnded=function(){return b=!0},a instanceof m?(this.consume=function(){return c[0]},this.push=function(a){return c=[a]},this.mayHave=function(){return!0},this.hasAtLeast=function(){return c.length}):(this.consume=function(){return c.shift()},this.push=function(a){return c.push(a)},this.mayHave=function(a){return!b||c.length>=a},this.hasAtLeast=function(a){return c.length>=a})}return a}(),o=O.map(function(a){return new b(a)},o),new h(function(b){var c,e,f;return e=function(a){return O.all(a.ixs,function(a){return o[a.index].hasAtLeast(a.count)})},c=function(a){return O.any(a.ixs,function(a){return!o[a.index].mayHave(a.count)})},f=function(f,g){return function(h){return f.subscribe(function(f){var i,j,l,m,n;if(f.isEnd())o[g].markEnded(),O.all(k,c)&&(j=a.noMore,b(t()));else if(f.isError())j=b(f);else for(o[g].push(f.value()),m=0,n=k.length;n>m;m++)if(i=k[m],e(i)){l=i.f.apply(i,function(){var a,b,c,e;for(c=i.ixs,e=[],a=0,b=c.length;b>a;a++)d=c[a],e.push(o[d.index].consume());return e}()),j=b(E(l));break}return j===a.noMore&&h(),j||a.more})}},s.apply(null,function(){var a,b,c;for(c=[],d=a=0,b=o.length;b>a;d=++a)n=o[d],c.push(f(n,d));return c}())})},a.update=function(){var b,c,d,e;for(c=arguments[0],e=2<=arguments.length?S.call(arguments,1):[],d=function(a){return function(){var b;return b=1<=arguments.length?S.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 a.when.apply(a,e).scan(c,function(a,b){return b(a)})},s=function(){var a;return a=1<=arguments.length?S.call(arguments,0):[],new c(a).unsubscribe},c=function(){function a(a){var b,c,d;for(null==a&&(a=[]),this.empty=V(this.empty,this),this.unsubscribe=V(this.unsubscribe,this),this.add=V(this.add,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,e=this;if(!this.unsubscribed)return b=!1,c=F,this.starting.push(a),d=function(){return c(),b=!0,e.remove(c),O.remove(a,e.starting)},c=a(this.unsubscribe,d),this.unsubscribed||b||this.subscriptions.push(c),O.remove(a,this.starting),c},a.prototype.remove=function(a){return this.unsubscribed?void 0:O.remove(a,this.subscriptions)},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],a();return this.subscriptions=[],this.starting=[]}},a.prototype.empty=function(){return!this.subscriptions.length&&!this.starting.length},a}(),p=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):k},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}(),k={getOrElse:function(a){return a},filter:function(){return k},map:function(){return k},forEach:function(){},isDefined:!1,toArray:function(){return[]}},a.EventStream=h,a.Property=m,a.Observable=l,a.Bus=b,a.Initial=i,a.Next=j,a.End=e,a.Error=f,F=function(){},z=function(a,b){return b},u=function(a){return a},w=function(a){return new i(O.always(a))},E=function(a){return new j(O.always(a))},t=function(){return new e},J=function(a){return a instanceof g?a:E(a)},r=function(a){return a.slice(0)},v=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},y=function(a){return"function"==typeof a},D=function(a,b,c){return void 0===c&&(c=[]),function(d){return a[b].apply(a,c.concat([d]))}},G=function(a,b){return function(){var c;return c=1<=arguments.length?S.call(arguments,0):[],a.apply(null,b.concat(c))}},C=function(a){return a instanceof l&&(a=O.always(a)),a},B=function(a,b){return y(a)?b.length?G(a,b):a:x(a)?K(a,b):"object"==typeof a&&b.length?D(a,O.head(b),O.tail(b)):O.always(a)},x=function(a){return"string"==typeof a&&a.length>1&&"."===a.charAt(0)},a.isFieldKey=x,K=function(a,b){var c,d;return d=a.slice(1).split("."),c=O.map(N(b),d),function(b){var d,e;for(d=0,e=c.length;e>d;d++)a=c[d],b=a(b);return b}},N=function(a){return function(b){return function(c){var d;return null==c?void 0:(d=c[b],y(d)?d.apply(c,a):d)}}},L=function(a){return a.slice(1)},I=function(a){var b;return y(a)?a:x(a)?(b=L(a),function(a,c){return a[b](c)}):void 0},M=function(a){return a instanceof p||a===k?a:new p(a)},"undefined"!=typeof define&&null!==define&&null!=define.amd&&"function"==typeof define&&define(function(){return a}),O={head:function(a){return a[0]},always:function(a){return function(){return a}},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,e;e=[];for(c in a)d=a[c],e.push(b(c,d));return e},toArray:function(a){return a instanceof Array?a:[a]},contains:function(a,b){return-1!==v(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=O.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=O.id),d=0,e=a.length;e>d;d++)if(c=a[d],b(c))return!0;return!1},without:function(a,b){return O.filter(function(b){return b!==a},b)},remove:function(a,b){var c;return c=v(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}},a._=O,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()}}}.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=[].slice,U={}.hasOwnProperty,V=function(a,b){function c(){this.constructor=a}for(var d in b)U.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},W=function(a,b){return function(){return a.apply(b,arguments)}};"undefined"!=typeof module&&null!==module?(module.exports=a={},a.Bacon=a):("function"==typeof require&&null!=require.amd&&define("bacon",[],function(){return a}),this.Bacon=a={}),a.fromBinder=function(b,c){return null==c&&(c=P.id),new h(function(d){var e;return e=b(function(){var b,f,h,i,j,k,l;for(b=1<=arguments.length?T.call(arguments,0):[],i=c.apply(null,b),i instanceof Array&&P.last(i)instanceof g||(i=[i]),l=[],j=0,k=i.length;k>j;j++)f=i[j],h=d(f=K(f)),h===a.noMore||f.isEnd()?null!=e?l.push(e()):l.push(a.scheduler.setTimeout(function(){return e()},0)):l.push(void 0);return l})})},a.$={asEventStream:function(b,c,d){var e,f=this;return z(c)&&(e=[c,null],d=e[0],c=e[1]),a.fromBinder(function(a){return f.on(b,c,a),function(){return f.off(b,c,a)}},d)}},null!=(Q="undefined"!=typeof jQuery&&null!==jQuery?jQuery:"undefined"!=typeof Zepto&&null!==Zepto?Zepto:null)&&(Q.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,a.fromBinder(function(a){return e.call(b,c,a),function(){return f.call(b,c,a)}},d)},a.fromPromise=function(b,c){return a.fromBinder(function(a){return b.then(a,function(b){return a(new f(b))}),function(){return c?"function"==typeof b.abort?b.abort():void 0:void 0}},function(a){return[a,u()]})},a.noMore=["<no-more>"],a.more=["<more>"],a.later=function(b,c){return a.sequentially(b,[c])},a.sequentially=function(b,c){var d;return d=0,a.fromPoll(b,function(){var a;return a=c[d++],d<c.length?a:d===c.length?[a,u()]:u()})},a.repeatedly=function(b,c){var d;return d=0,a.fromPoll(b,function(){return c[d++%c.length]})},B=function(b){return function(){var c,d,e;return d=arguments[0],c=2<=arguments.length?T.call(arguments,1):[],e=H(b,[function(a,b){return d.apply(null,T.call(a).concat([b]))}]),a.combineAsArray(c).flatMap(e)}},a.fromCallback=B(function(){var b,c;return c=arguments[0],b=2<=arguments.length?T.call(arguments,1):[],a.fromBinder(function(a){return C(c,b)(a),G},function(a){return[a,u()]})}),a.fromNodeCallback=B(function(){var b,c;return c=arguments[0],b=2<=arguments.length?T.call(arguments,1):[],a.fromBinder(function(a){return C(c,b)(a),G},function(a,b){return a?[new f(a),u()]:[b,u()]})}),a.fromPoll=function(b,c){return 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={}),a.fromPoll(b,function(){return F(c)})},a.constant=function(a){return new m(I([a],x),!0)},a.never=function(){return a.fromArray([])},a.once=function(b){return a.fromArray([b])},a.fromArray=function(a){return new h(I(a,K))},I=function(a,b){return function(c){var d,e,f;for(e=0,f=a.length;f>e;e++)d=a[e],c(b(d));return c(u()),G}},a.mergeAll=function(){var b,c;return c=arguments[0],b=2<=arguments.length?T.call(arguments,1):[],c instanceof Array||(c=[c].concat(b)),P.fold(c,a.never(),function(a,b){return a.merge(b)})},a.zipAsArray=function(){var b,c;return c=arguments[0],b=2<=arguments.length?T.call(arguments,1):[],c instanceof Array||(c=[c].concat(b)),a.zipWith(c,Array)},a.zipWith=function(){var b,c,d,e;return d=arguments[0],b=arguments[1],c=3<=arguments.length?T.call(arguments,2):[],z(d)&&(e=[[b].concat(c),d],d=e[0],b=e[1]),a.when(d,b)},a.combineAsArray=function(){var b,c,d,e;return d=arguments[0],b=2<=arguments.length?T.call(arguments,1):[],d instanceof Array||(d=[d].concat(b)),d.length?(e=function(){var a,b,e;for(e=[],a=0,b=d.length;b>a;a++)c=d[a],e.push(k);return e}(),new m(function(b){var f,g,h,i,j,k,m,n,o,q,r,s;for(q=!1,o=function(){var a,b,e;for(e=[],a=0,b=d.length;b>a;a++)c=d[a],e.push(G);return e}(),n=function(){var a,b,c;for(b=0,c=o.length;c>b;b++)a=o[b],a();return q=!0},h=function(){var a,b,e;for(e=[],a=0,b=d.length;b>a;a++)c=d[a],e.push(!1);return e}(),f=function(){var c;return P.all(h)?(c=b(u()),c===a.noMore&&n(),c):void 0},j=!1,g=function(c,d){return function(g){var h,i;return g.isEnd()?(c(),f(),a.noMore):g.isError()?(h=b(g),h===a.noMore&&n(),h):(d(g.value),P.all(P.map(function(a){return a.isDefined},e))?j&&g.isInitial()?a.more:(j=!0,i=function(){var a,b,c,d;for(d=[],b=0,c=e.length;c>b;b++)a=e[b],d.push(a.get()());return d},h=b(g.apply(i)),h===a.noMore&&n(),h):a.more)}},k=function(a){return g(function(){return h[a]=!0},function(b){return e[a]=new p(b)})},i=r=0,s=d.length;s>r;i=++r)m=d[i],m instanceof l||(m=a.constant(m)),q||(o[i]=m.subscribeInternal(k(i)));return n})):a.constant([])},a.onValues=function(){var b,c,d;return c=2<=arguments.length?T.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?T.call(arguments,1):[],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,m;return i=[],m=[],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 a instanceof Array?[]:{}},e=function(a,b){var d,e;return b instanceof l?(m.push(b),i.push(c(a,m.length-1))):b===Object(b)&&"function"!=typeof 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)):i.push(g(a,b))},f=function(a){return P.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],d(c,a);return e},a.combineAsArray(m).map(d)},g=function(){function a(){}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}(),j=function(a){function b(a){var b=this;this.value=z(a)?function(){var c;return c=a(),b.value=P.always(c),c}:P.always(a)}return V(b,a),b.prototype.isNext=function(){return!0},b.prototype.hasValue=function(){return!0},b.prototype.fmap=function(a){var b=this;return this.apply(function(){return a(b.value())})},b.prototype.apply=function(a){return new b(a)},b.prototype.filter=function(a){return a(this.value())},b.prototype.describe=function(){return this.value()},b}(g),i=function(a){function b(){return R=b.__super__.constructor.apply(this,arguments)}return V(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 j(this.value)},b}(j),e=function(a){function b(){return S=b.__super__.constructor.apply(this,arguments)}return V(b,a),b.prototype.isEnd=function(){return!0},b.prototype.fmap=function(){return this},b.prototype.apply=function(){return this},b.prototype.describe=function(){return"<end>"},b}(g),f=function(a){function b(a){this.error=a}return V(b,a),b.prototype.isError=function(){return!0},b.prototype.fmap=function(){return this},b.prototype.apply=function(){return this},b.prototype.describe=function(){return"<error> "+this.error},b}(g),l=function(){function b(){this.combine=W(this.combine,this),this.flatMapLatest=W(this.flatMapLatest,this),this.fold=W(this.fold,this),this.scan=W(this.scan,this),this.assign=this.onValue}return b.prototype.onValue=function(){var a,b;return b=arguments[0],a=2<=arguments.length?T.call(arguments,1):[],b=C(b,a),this.subscribe(function(a){return a.hasValue()?b(a.value()):void 0})},b.prototype.onValues=function(a){return this.onValue(function(b){return a.apply(null,b)})},b.prototype.onError=function(){var a,b;return b=arguments[0],a=2<=arguments.length?T.call(arguments,1):[],b=C(b,a),this.subscribe(function(a){return a.isError()?b(a.error):void 0})},b.prototype.onEnd=function(){var a,b;return b=arguments[0],a=2<=arguments.length?T.call(arguments,1):[],b=C(b,a),this.subscribe(function(a){return a.isEnd()?b():void 0})},b.prototype.errors=function(){return this.filter(function(){return!1})},b.prototype.filter=function(){var b,c;return c=arguments[0],b=2<=arguments.length?T.call(arguments,1):[],t(this,c,b,function(b){return 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?T.call(arguments,1):[],t(this,c,b,function(b){return this.withHandler(function(c){return c.filter(b)?this.push(c):(this.push(u()),a.noMore)})})},b.prototype.endOnError=function(){return this.withHandler(function(a){return a.isError()?(this.push(a),this.push(u())):this.push(a)})},b.prototype.take=function(b){return 0>=b?a.never():this.withHandler(function(c){return c.hasValue()?(b--,b>0?this.push(c):(0===b&&this.push(c),this.push(u()),a.noMore)):this.push(c)})},b.prototype.map=function(){var a,b;return b=arguments[0],a=2<=arguments.length?T.call(arguments,1):[],b instanceof m?b.sampledBy(this,v):t(this,b,a,function(a){return this.withHandler(function(b){return this.push(b.fmap(a))})})},b.prototype.mapError=function(){var a,b;return b=arguments[0],a=2<=arguments.length?T.call(arguments,1):[],b=C(b,a),this.withHandler(function(a){return a.isError()?this.push(F(b(a.error))):this.push(a)})},b.prototype.mapEnd=function(){var b,c;return c=arguments[0],b=2<=arguments.length?T.call(arguments,1):[],c=C(c,b),this.withHandler(function(b){return b.isEnd()?(this.push(F(c(b))),this.push(u()),a.noMore):this.push(b)})},b.prototype.doAction=function(){var a,b;return b=arguments[0],a=2<=arguments.length?T.call(arguments,1):[],b=C(b,a),this.withHandler(function(a){return a.hasValue()&&b(a.value()),this.push(a)})},b.prototype.skip=function(b){return this.withHandler(function(c){return c.hasValue()?b>0?(b--,a.more):this.push(c):this.push(c)})},b.prototype.skipDuplicates=function(a){return null==a&&(a=function(a,b){return a===b}),this.withStateMachine(k,function(b,c){return c.hasValue()?b!==k&&a(b.get(),c.value())?[b,[]]:[new p(c.value()),[c]]:[b,[c]]})},b.prototype.skipErrors=function(){return this.withHandler(function(b){return b.isError()?a.more:this.push(b)})},b.prototype.withStateMachine=function(b,c){var d;return d=b,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){var d,e,f=this;return c=J(c),d=N(b),e=function(b){var e,g,h,i;return e=!1,i=G,g=a.more,h=function(){return e?void 0:(e=!0,d.forEach(function(c){return g=b(x(c)),g===a.noMore?(i(),i=G):void 0}))},i=f.subscribe(function(f){return f.hasValue()?e&&f.isInitial()?a.more:(e=!0,d=new p(c(d.getOrElse(void 0),f.value())),b(f.apply(P.always(d.get())))):(f.isEnd()&&(g=h()),g!==a.noMore?b(f):void 0)}),h(),i},new m(e)},b.prototype.fold=function(a,b){return this.scan(a,b).sampledBy(this.filter(!1).mapEnd().toProperty())},b.prototype.zip=function(b,c){return null==c&&(c=Array),a.zipWith([this,b],c)},b.prototype.diff=function(a,b){return b=J(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(c,d){var e;return c=D(c),e=this,new h(function(f){var g,h,j,k,l,m;return h=[],j=!1,m=function(){},l=function(){var a,b,c;for(m(),b=0,c=h.length;c>b;b++)a=h[b],a();return h=[]},g=function(){return j&&0===h.length?f(u()):void 0},k=function(e){var k,m,n,o,p;return e.isEnd()?(j=!0,g()):e.isError()?f(e):d&&h.length?a.more:(k=c(e.value()),k instanceof b||(k=a.once(k)),p=void 0,m=!1,o=function(){return null!=p&&P.remove(p,h),g()},n=function(b){var c;return b.isEnd()?(o(),m=!0,a.noMore):(b instanceof i&&(b=b.toNext()),c=f(b),c===a.noMore&&l(),c)},p=k.subscribe(n),m?void 0:h.push(p))},m=e.subscribe(k),l})},b.prototype.flatMapFirst=function(a){return this.flatMap(a,!0)},b.prototype.flatMapLatest=function(a){var b;return a=D(a),b=this.toEventStream(),b.flatMap(function(c){return a(c).takeUntil(b)})},b.prototype.not=function(){return this.map(function(a){return!a})},b.prototype.log=function(){var a;return a=1<=arguments.length?T.call(arguments,0):[],this.subscribe(function(b){return"undefined"!=typeof console&&null!==console?"function"==typeof console.log?console.log.apply(console,T.call(a).concat([b.describe()])):void 0:void 0}),this},b.prototype.slidingWindow=function(a,b){return null==b&&(b=0),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=J(c),a.combineAsArray(this,b).map(function(a){return d(a[0],a[1])})},b.prototype.decode=function(b){return this.combine(a.combineTemplate(b),function(a,b){return b[a]})},b}(),l.prototype.reduce=l.prototype.fold,h=function(b){function c(a){this.takeUntil=W(this.takeUntil,this);var b;c.__super__.constructor.call(this),b=new d(a),this.subscribe=b.subscribe,this.subscribeInternal=this.subscribe,this.hasSubscribers=b.hasSubscribers}return V(c,b),c.prototype.delay=function(b){return this.flatMap(function(c){return a.later(b,c)})},c.prototype.debounce=function(b){return this.flatMapLatest(function(c){return a.later(b,c)})},c.prototype.debounceImmediate=function(b){return this.flatMapFirst(function(c){return a.once(c).concat(a.later(b).filter(!1))})},c.prototype.throttle=function(a){return this.bufferWithTime(a).map(function(a){return a[a.length-1]})},c.prototype.bufferWithTime=function(a){return this.bufferWithTimeOrCount(a,Number.MAX_VALUE)},c.prototype.bufferWithCount=function(a){return 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},this.buffer(a,c,c)},c.prototype.buffer=function(b,c,d){var e,f,g;return null==c&&(c=function(){}),null==d&&(d=function(){}),e={scheduled:!1,end:null,values:[],flush:function(){var b;if(this.scheduled=!1,this.values.length>0){if(b=this.push(F(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(){var a=this;return this.scheduled?void 0:(this.scheduled=!0,b(function(){return a.flush()}))}},g=a.more,z(b)||(f=b,b=function(b){return a.scheduler.setTimeout(b,f)}),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 d;return d=this,new c(function(c){var e,f,g,h,i,j;return h=G,i=G,j=!1,g=function(){return h(),i(),j=!0},e=0,f=function(b){var d;return b.isEnd()?(e++,2===e?c(u()):a.more):(d=c(b),d===a.noMore&&g(),d)},h=d.subscribe(f),j||(i=b.subscribe(f)),g})},c.prototype.toProperty=function(a){return 0===arguments.length&&(a=k),this.scan(a,A)},c.prototype.toEventStream=function(){return this},c.prototype.concat=function(a){var b;return b=this,new c(function(c){var d;return d=b.subscribe(function(b){return b.isEnd()?d=a.subscribe(c):c(b)}),function(){return d()}})},c.prototype.takeUntil=function(a){var b,c;return b=a.skipErrors().map(!0).toProperty(!1).take(2),c=b.combine(this,function(a,b){return{value:b,stopped:a}}).takeWhile(function(a){var b;return b=a.stopped,!b}).changes().map(function(a){var b;return b=a.value})},c.prototype.skipUntil=function(a){var b;return b=a.map(!0).toProperty(!1).take(2),b.sampledBy(this,function(a,b){return{val:b,started:a}}).filter(function(a){var b;return b=a.started}).map(function(a){var b;return b=a.val})},c.prototype.skipWhile=function(){var a,b;return b=arguments[0],a=2<=arguments.length?T.call(arguments,1):[],t(this,b,a,function(a){return this.skipUntil(this.filter(P.negate(a)))})},c.prototype.awaiting=function(a){return this.map(!0).merge(a.map(!1)).toProperty(!1)},c.prototype.startWith=function(b){return a.once(b).concat(this)},c.prototype.withHandler=function(a){var b;return b=new d(this.subscribe,a),new c(b.subscribe)},c.prototype.withSubscribe=function(a){return new c(a)},c}(l),m=function(b){function c(b,d){this.toEventStream=W(this.toEventStream,this),this.toProperty=W(this.toProperty,this),this.changes=W(this.changes,this),this.sample=W(this.sample,this);var e=this;c.__super__.constructor.call(this),this.subscribeInternal=d===!0?b:new n(b,d).subscribe,this.sampledBy=function(a,d){var f,g;return f=null!=d?(d=J(d),function(a,b){return d(a.value(),b.value())}):function(a){return a.value()},g=k,b=function(b){var c,d,h,i;return i=!1,d=G,h=G,c=function(){return d(),h(),i=!0},d=e.subscribeInternal(function(a){return a.hasValue()?g=new p(a):a.isError()?b(a):void 0}),h=a.subscribe(function(a){return a.hasValue()?g.forEach(function(c){return b(a.apply(f(c,a)))}):(a.isEnd()&&d(),b(a))}),c},a instanceof c?new c(b):new h(b)},this.subscribe=function(b){var c,d,f,g,h;return f=a.more,c=function(){function c(){}return c.prototype.set=function(a){return this.event=a},c.prototype.send=function(){var c;return c=this.event,this.event=null,null!=c&&f!==a.noMore&&(f=b(c),f===a.noMore)?g():void 0},c}(),h=new c,d=new c,g=G,g=e.subscribeInternal(function(c){return c.isError()?f!==a.noMore&&(f=b(c)):(c.hasValue()?h.set(c):c.isEnd()&&d.set(c),o.onDone(function(){return h.send(),d.send()})),f}),function(){return f=a.noMore,g()}}}return V(c,b),c.prototype.sample=function(b){return this.sampledBy(a.interval(b,{}))},c.prototype.changes=function(){var a=this;return new h(function(b){return a.subscribe(function(a){return a.isInitial()?void 0:b(a)})})},c.prototype.withHandler=function(a){return new c(this.subscribeInternal,a)},c.prototype.withSubscribe=function(a){return new c(a)},c.prototype.toProperty=function(){return this},c.prototype.toEventStream=function(){var a=this;return new h(function(b){return a.subscribe(function(a){return a.isInitial()&&(a=a.toNext()),b(a)})})},c.prototype.and=function(a){return this.combine(a,function(a,b){return a&&b})},c.prototype.or=function(a){return this.combine(a,function(a,b){return a||b})},c.prototype.delay=function(a){return this.delayChanges(function(b){return b.delay(a)})},c.prototype.debounce=function(a){return this.delayChanges(function(b){return b.debounce(a)})},c.prototype.throttle=function(a){return this.delayChanges(function(b){return b.throttle(a)})},c.prototype.delayChanges=function(a){return q(this,a(this.changes()))},c.prototype.takeUntil=function(a){var b;return b=this.changes().takeUntil(a),q(this,b)},c}(l),t=function(a,b,c,d){var e;return b instanceof m?(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=C(b,c),d.apply(a,[b]))},q=function(b,c){var d;return d=function(b){var c;return c=k,b.subscribe(function(b){return b.hasValue()&&(c=new p(b.value())),a.noMore}),c},c.toProperty(d(b))},d=function(){function b(b,c){var d,e,f,g,h,i,j,k,l,m=this;null==b&&(b=function(){return G}),j=[],h=null,g=!1,e=!1,this.hasSubscribers=function(){return j.length>0},f=null,k=G,i=function(a){return j=P.without(a,j)},l=null,d=function(){var a,b,c,d,e;if(null!=l){for(b=l,l=null,e=[],c=0,d=b.length;d>c;c++)a=b[c],e.push(a());return e}},this.push=function(b){var c,e,k,l,n,o;if(g)return h=(h||[]).concat([b]),a.more;if(b!==f){b.isError()&&(f=b),k=!1;try{for(g=!0,l=j,n=0,o=l.length;o>n;n++)e=l[n],c=e.sink(b),(c===a.noMore||b.isEnd())&&i(e);k=!0}finally{g=!1,k||(h=null)}for(k=!0;null!=h?h.length:void 0;)b=P.head(h),h=P.tail(h),m.push(b);return d(b),m.hasSubscribers()?a.more:a.noMore}},null==c&&(c=function(a){return this.push(a)}),this.handleEvent=function(a){return a.isEnd()&&(e=!0),c.apply(m,[a])},this.subscribe=function(a){var c;return e?(a(u()),G):(c={sink:a},j=j.concat(c),1===j.length&&(k=b(m.handleEvent)),function(){return i(c),m.hasSubscribers()?void 0:k()})}}return b}(),n=function(b){function c(b,d){var e,f,g,h=this;c.__super__.constructor.call(this,b,d),e=k,g=this.push,b=this.subscribe,f=!1,this.push=function(a){return a.isEnd()&&(f=!0),a.hasValue()&&(e=new p(a.value())),o.inTransaction(function(){return g.apply(h,[a])})},this.subscribe=function(c){var d,g,i;return d=!1,i=function(){return h.hasSubscribers()||f},g=e.filter(i).map(function(a){return c(x(a))}),g.getOrElse(a.more)===a.noMore?G:f?(c(u()),G):b.apply(h,[c])}}return V(c,b),c}(d),o=function(){var a,b,c,d;return d=[],c=!1,b=function(a){return c?d.push(a):a()},a=function(a){var b,e,f,g,h;if(c)return a();c=!0;try{f=a()}finally{c=!1}for(e=d,d=[],g=0,h=e.length;h>g;g++)b=e[g],b();return f},{onDone:b,inTransaction:a}}(),b=function(b){function c(){var b,d,e,g,h,i,j,k;e=void 0,i=[],b=!1,d=function(b){return function(c){return c.isEnd()?(k(b),a.noMore):e(c)}},j=function(){var a,b,c,d;for(d=[],b=0,c=i.length;c>b;b++)a=i[b],d.push("function"==typeof a.unsub?a.unsub():void 0);return d},h=function(a){return a.unsub=a.input.subscribe(d(a.input))},k=function(a){var b,c,d,e;for(b=d=0,e=i.length;e>d;b=++d)if(c=i[b],c.input===a)return"function"==typeof c.unsub&&c.unsub(),i.splice(b,1),void 0},g=function(a){var b,c,d,f,g;for(e=a,c=[],g=r(i),d=0,f=g.length;f>d;d++)b=g[d],h(b);return j},c.__super__.constructor.call(this,g),this.plug=function(a){var c;if(!b)return c={input:a},i.push(c),null!=e&&h(c),function(){return k(a)}},this.push=function(a){return"function"==typeof e?e(F(a)):void 0},this.error=function(a){return"function"==typeof e?e(new f(a)):void 0},this.end=function(){return b=!0,j(),"function"==typeof e?e(u()):void 0}}return V(c,b),c}(h),a.when=function(){var b,c,d,e,f,g,i,j,k,l,n,o,p,q,r,t,v,w;if(l=1<=arguments.length?T.call(arguments,0):[],0===l.length)return a.never();for(g=l.length,p="when: expecting arguments in the form (Observable+,function)+",o=[],k=[],d=0;g>d;){for(j=P.toArray(l[d]),c=l[d+1],i={f:z(c)?c:function(){return c},ixs:[]},q=0,t=j.length;t>q;q++){for(n=j[q],e=o.indexOf(n),0>e&&(o.push(n),e=o.length-1),w=i.ixs,r=0,v=w.length;v>r;r++)f=w[r],f.index===e&&f.count++;i.ixs.push({index:e,count:1})}k.push(i),d+=2}return b=function(){function a(a){var b,c;c=[],b=!1,this.subscribe=a.subscribe,this.markEnded=function(){return b=!0},a instanceof m?(this.consume=function(){return c[0]},this.push=function(a){return c=[a]},this.mayHave=function(){return!0},this.hasAtLeast=function(){return c.length}):(this.consume=function(){return c.shift()},this.push=function(a){return c.push(a)},this.mayHave=function(a){return!b||c.length>=a},this.hasAtLeast=function(a){return c.length>=a})}return a}(),o=P.map(function(a){return new b(a)},o),new h(function(b){var c,e,f;return e=function(a){return P.all(a.ixs,function(a){return o[a.index].hasAtLeast(a.count)})},c=function(a){return P.any(a.ixs,function(a){return!o[a.index].mayHave(a.count)})},f=function(f,g){return function(h){return f.subscribe(function(f){var i,j,l,m,n;if(f.isEnd())o[g].markEnded(),P.all(k,c)&&(j=a.noMore,b(u()));else if(f.isError())j=b(f);else for(o[g].push(f.value()),m=0,n=k.length;n>m;m++)if(i=k[m],e(i)){l=i.f.apply(i,function(){var a,b,c,e;for(c=i.ixs,e=[],a=0,b=c.length;b>a;a++)d=c[a],e.push(o[d.index].consume());return e}()),j=b(F(l));break}return j===a.noMore&&h(),j||a.more})}},s.apply(null,function(){var a,b,c;for(c=[],d=a=0,b=o.length;b>a;d=++a)n=o[d],c.push(f(n,d));return c}())})},a.update=function(){var b,c,d,e;for(c=arguments[0],e=2<=arguments.length?T.call(arguments,1):[],d=function(a){return function(){var b;return b=1<=arguments.length?T.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 a.when.apply(a,e).scan(c,function(a,b){return b(a)})},s=function(){var a;return a=1<=arguments.length?T.call(arguments,0):[],new c(a).unsubscribe},c=function(){function a(a){var b,c,d;for(null==a&&(a=[]),this.empty=W(this.empty,this),this.unsubscribe=W(this.unsubscribe,this),this.add=W(this.add,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,e=this;if(!this.unsubscribed)return b=!1,c=G,this.starting.push(a),d=function(){return c(),b=!0,e.remove(c),P.remove(a,e.starting)},c=a(this.unsubscribe,d),this.unsubscribed||b||this.subscriptions.push(c),P.remove(a,this.starting),c},a.prototype.remove=function(a){return this.unsubscribed?void 0:P.remove(a,this.subscriptions)},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],a();return this.subscriptions=[],this.starting=[]}},a.prototype.empty=function(){return!this.subscriptions.length&&!this.starting.length},a}(),p=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):k},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}(),k={getOrElse:function(a){return a},filter:function(){return k},map:function(){return k},forEach:function(){},isDefined:!1,toArray:function(){return[]}},a.EventStream=h,a.Property=m,a.Observable=l,a.Bus=b,a.Initial=i,a.Next=j,a.End=e,a.Error=f,G=function(){},A=function(a,b){return b},v=function(a){return a},x=function(a){return new i(P.always(a))},F=function(a){return new j(P.always(a))},u=function(){return new e},K=function(a){return a instanceof g?a:F(a)},r=function(a){return a.slice(0)},w=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},z=function(a){return"function"==typeof a},E=function(a,b,c){return void 0===c&&(c=[]),function(d){return a[b].apply(a,c.concat([d]))}},H=function(a,b){return function(){var c;return c=1<=arguments.length?T.call(arguments,0):[],a.apply(null,b.concat(c))}},D=function(a){return a instanceof l&&(a=P.always(a)),a},C=function(a,b){return z(a)?b.length?H(a,b):a:y(a)?L(a,b):"object"==typeof a&&b.length?E(a,P.head(b),P.tail(b)):P.always(a)},y=function(a){return"string"==typeof a&&a.length>1&&"."===a.charAt(0)},a.isFieldKey=y,L=function(a,b){var c,d;return d=a.slice(1).split("."),c=P.map(O(b),d),function(b){var d,e;for(d=0,e=c.length;e>d;d++)a=c[d],b=a(b);return b}},O=function(a){return function(b){return function(c){var d;return null==c?void 0:(d=c[b],z(d)?d.apply(c,a):d)}}},M=function(a){return a.slice(1)},J=function(a){var b;return z(a)?a:y(a)?(b=M(a),function(a,c){return a[b](c)}):void 0},N=function(a){return a instanceof p||a===k?a:new p(a)},"undefined"!=typeof define&&null!==define&&null!=define.amd&&"function"==typeof define&&define(function(){return a}),P={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,e;e=[];for(c in a)d=a[c],e.push(b(c,d));return e},toArray:function(a){return a instanceof Array?a:[a]},contains:function(a,b){return-1!==w(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=P.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=P.id),d=0,e=a.length;e>d;d++)if(c=a[d],b(c))return!0;return!1},without:function(a,b){return P.filter(function(b){return b!==a},b)},remove:function(a,b){var c;return c=w(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}},a._=P,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()}}}.call(this); |
{ | ||
"name": "baconjs", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"author": "Juha Paananen", | ||
@@ -20,3 +20,5 @@ "licenses": [ | ||
"sinon": "~1.6.0", | ||
"grunt-contrib-uglify": "~0.2.2" | ||
"grunt-contrib-uglify": "~0.2.2", | ||
"chai": "1.6.0", | ||
"mocha": "1.10.0" | ||
}, | ||
@@ -70,3 +72,3 @@ "repository": { | ||
"scripts": { | ||
"test": "jasmine-node --coffee spec", | ||
"test": "./node_modules/mocha/bin/mocha --compilers coffee:coffee-script spec/**", | ||
"pre-publish": "grunt" | ||
@@ -73,0 +75,0 @@ }, |
@@ -21,2 +21,3 @@ Bacon.js | ||
- [Wiki](https://github.com/raimohanska/bacon.js/wiki/) with more docs, related projects and more | ||
- [Cheat Sheet](http://www.cheatography.com/proloser/cheat-sheets/bacon-js/) | ||
- [My Blog](http://nullzzz.blogspot.com) with some baconful and reactive postings along with a Bacon.js tutorial | ||
@@ -345,4 +346,8 @@ - [TodoMVC with Bacon.js and jQuery](https://github.com/raimohanska/todomvc/blob/bacon-jquery/labs/architecture-examples/baconjs/js/app.js) | ||
`observable.takeWhile(f)` takes while given predicate function holds true | ||
`observable.takeWhile(f)` takes while given predicate function holds | ||
true. Function Construction rules apply. | ||
`observable.takeWhile(property)` takes values while the value of a | ||
property holds `true`. | ||
`observable.take(n)` takes at most n elements from the stream. Equals to | ||
@@ -639,2 +644,7 @@ Bacon.never() if n <= 0. | ||
`stream.skipWhile(f)` skips elements while given predicate function holds true. Function construction rules apply. | ||
`stream.skipWhile(property)` skips elements while the value of the given | ||
Property is `true`. | ||
`stream.skipUntil(stream2)` skips elements from `stream` until a Next event | ||
@@ -641,0 +651,0 @@ appears in `stream2`. In other words, starts delivering values |
@@ -0,1 +1,14 @@ | ||
## 0.6 | ||
- Add EventStream.skipWhile, support "Property Bool" instead of predicate function in takeWhile (#204) | ||
skipWhile | ||
- Fix Property.take(n) etc in case of a never-ending Property (#205) | ||
- Fix EventStream.skipUntil in case of self-derived stopper | ||
- Re-implement EventStream.takeUntil | ||
- Switch test framework from Jasmine to Mocha | ||
## 0.5.1 | ||
- Fix bug in Bacon.update (#199) | ||
## 0.5.0 | ||
@@ -2,0 +15,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
632344
12982
1411
13