Socket
Socket
Sign inDemoInstall

baconjs

Package Overview
Dependencies
Maintainers
2
Versions
224
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baconjs - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

.babelrc

4

CONTRIBUTING.md
Use [GitHub issues](https://github.com/baconjs/bacon.js/issues) and [Pull Requests](https://github.com/baconjs/bacon.js/pulls).
Note:
- the `README.md` is generated from `readme-src.coffee`. After updating the source file, run `grunt readme`.
- the `dist/Bacon.coffee` is assembled from files in `src/`. After updating source files, run `grunt assemble` or `./assemble.js`.
- the `README.md` is generated from `readme-src.coffee`. After updating the source file, run `npm run readme`.
- the `dist/Bacon*.js` files are assembled from files in `src/`. After updating source files, run `npm run dist`.

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

(function(){function t(t,n){var r=!(arguments.length<=2||void 0===arguments[2])&&arguments[2];this.obs=t,this.sync=n,this.lazy=r,this.queue=[]}function n(){t.apply(this,arguments)}function r(n){t.call(this,n,!0)}function e(t,n,r){this.context=t,this.method=n,this.args=r}function i(t){this.value=t}function u(){this.id=++G}function o(t,n){if(!(this instanceof o))return new o(t,n);u.call(this),!n&&_.isFunction(t)||(null!=t?t._isNext:void 0)?(this.valueF=t,this.valueInternal=void 0):(this.valueF=void 0,this.valueInternal=t)}function s(t,n){if(!(this instanceof s))return new s(t,n);o.call(this,t,n)}function c(){if(!(this instanceof c))return new c;u.call(this)}function a(t){if(!(this instanceof a))return new a(t);this.error=t,u.call(this)}function f(t){this.desc=t,this.id=++nt,this.initialDesc=this.desc}function h(){var t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0];this.unsubscribe=_.bind(this.unsubscribe,this),this.unsubscribed=!1,this.subscriptions=[],this.starting=[];for(var n,r=0;r<t.length;r++)n=t[r],this.add(n)}function l(t,n){this._subscribe=t,this._handleEvent=n,this.subscribe=_.bind(this.subscribe,this),this.handleEvent=_.bind(this.handleEvent,this),this.pushing=!1,this.ended=!1,this.prevError=void 0,this.unsubSrc=void 0,this.subscriptions=[],this.queue=[]}function p(t,n,r){if(!(this instanceof p))return new p(t,n,r);_.isFunction(t)&&(r=n,n=t,t=e.empty),f.call(this,t),this.dispatcher=new l(n,r),rt(this)}function v(t,n,r){l.call(this,n,r),this.property=t,this.subscribe=_.bind(this.subscribe,this),this.current=Z,this.currentValueRootId=void 0,this.propertyEnded=!1}function d(t,n,r){f.call(this,t),this.dispatcher=new v(this,n,r),rt(this)}function b(t,n){var r=new p(V(t,"justInitValue"),function(n){var e=void 0,i=t.dispatcher.subscribe(function(t){return t.isEnd()||(e=t),E.noMore});return T.whenDoneWith(r,function(){return void 0!==e&&null!==e&&n(e),n(Y())}),i});return r.concat(n).toProperty()}function y(){if(!(this instanceof y))return new y;this.unsubAll=_.bind(this.unsubAll,this),this.subscribeAll=_.bind(this.subscribeAll,this),this.guardedSink=_.bind(this.guardedSink,this),this.sink=void 0,this.subscriptions=[],this.ended=!1,p.call(this,new E.Desc(E,"Bus",[]),this.subscribeAll)}function m(t){return[t,Y()]}function g(t){this.observable=t}var w=Array.prototype.slice,E={toString:function(){return"Bacon"}};E.version="1.0.1";var S=("undefined"!=typeof global&&null!==global?global:this).Error,D=function(){},A=function(t,n){return t},O=function(t){return t.slice(0)},M=Array.isArray||function(t){return t instanceof Array},k=function(t){return t&&t._isObservable},I=function(t){for(var n=arguments.length,r=1;1<n?r<n:r>n;1<n?r++:r--)for(var e in arguments[r])t[e]=arguments[r][e];return t},x=function(t,n){var r={}.hasOwnProperty,e=function(){};e.prototype=n.prototype,t.prototype=new e;for(var i in n)r.call(n,i)&&(t[i]=n[i]);return t},P=function(t){return"undefined"!=typeof Symbol&&Symbol[t]?Symbol[t]:"undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol[t]=Symbol.for(t):"@@"+t},_={indexOf:function(){return Array.prototype.indexOf?function(t,n){return t.indexOf(n)}:function(t,n){for(var r,e=0;e<t.length;e++)if(r=t[e],n===r)return e;return-1}}(),indexWhere:function(t,n){for(var r,e=0;e<t.length;e++)if(r=t[e],n(r))return e;return-1},head:function(t){return t[0]},always:function(t){return function(){return t}},negate:function(t){return function(n){return!t(n)}},empty:function(t){return 0===t.length},tail:function(t){return t.slice(1,t.length)},filter:function(t,n){for(var r,e=[],i=0;i<n.length;i++)r=n[i],t(r)&&e.push(r);return e},map:function(t,n){return function(){for(var r,e=[],i=0;i<n.length;i++)r=n[i],e.push(t(r));return e}()},each:function(t,n){for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var e=t[r];n(r,e)}},toArray:function(t){return M(t)?t:[t]},contains:function(t,n){return-1!==_.indexOf(t,n)},id:function(t){return t},last:function(t){return t[t.length-1]},all:function(t){for(var n,r=arguments.length<=1||void 0===arguments[1]?_.id:arguments[1],e=0;e<t.length;e++)if(n=t[e],!r(n))return!1;return!0},any:function(t){for(var n,r=arguments.length<=1||void 0===arguments[1]?_.id:arguments[1],e=0;e<t.length;e++)if(n=t[e],r(n))return!0;return!1},without:function(t,n){return _.filter(function(n){return n!==t},n)},remove:function(t,n){var r=_.indexOf(n,t);if(r>=0)return n.splice(r,1)},fold:function(t,n,r){for(var e,i=0;i<t.length;i++)e=t[i],n=r(n,e);return n},flatMap:function(t,n){return _.fold(n,[],function(n,r){return n.concat(t(r))})},cached:function(t){var n=Z;return function(){return(void 0!==n&&null!==n?n._isNone:void 0)&&(n=t(),t=void 0),n}},bind:function(t,n){return function(){return t.apply(n,arguments)}},isFunction:function(t){return"function"==typeof t},toString:function(t){var n,r,e={}.hasOwnProperty;try{return W++,null==t?"undefined":_.isFunction(t)?"function":M(t)?W>5?"[..]":"["+_.map(_.toString,t).toString()+"]":null!=(null!=t?t.toString:void 0)&&t.toString!==Object.prototype.toString?t.toString():"object"==typeof t?W>5?"{..}":"{"+function(){var i=[];for(n in t)e.call(t,n)&&(r=function(){try{return t[n]}catch(t){return t}}(),i.push(_.toString(n)+":"+_.toString(r)));return i}()+"}":t}finally{W--}}},W=0;E._=_;var T=E.UpdateBarrier=function(){function t(t){t<=s||(o[t-1]||(o[t-1]=[[],0]),s=t)}function n(t,n){for(var r=0;r<n.length;r++)if(n[r][0].id==t.id)return!0;return!1}function r(){var n=s;if(n)for(;s>=n;){var r=o[s-1];if(!r)throw new a("Unexpected stack top: "+r);var e=r[0],i=r[1];if(!(i<e.length)){r[0]=[],r[1]=0;break}var u=e[i],c=(u[0],u[1]);r[1]++,t(s+1);var f=!1;try{for(c(),f=!0;s>n&&0==o[s-1][0].length;)s--}finally{f||(o=[],s=0)}}}var e,i=[],u={},o=[],s=0,c={},f=function(i,u){if(!e&&!o.length)return u();t(1);for(var c=0;c<s-1&&!n(i,o[c][0]);)c++;o[c][0].push([i,u]),e||r()},h=function(t,n){if(e){var r=u[t.id];return void 0===r||null===r?(r=u[t.id]=[n],i.push(t)):r.push(n)}return n()},l=function(){for(;i.length>0;)p(0,!0);c={}},p=function(t,n){var r=i[t],e=r.id,o=u[e];i.splice(t,1),delete u[e],n&&i.length>0&&v(r);for(var s=0;s<o.length;s++)(0,o[s])()},v=function(t){if(!c[t.id]){for(var n,r=t.internalDeps(),e=0;e<r.length;e++)if(n=r[e],v(n),u[n.id]){var o=_.indexOf(i,n);p(o,!1)}c[t.id]=!0}},d=function(t,n,i,u){if(e)return i.apply(n,u);e=t;try{var o=i.apply(n,u);l()}finally{e=void 0,r()}return o},b=function(){return e?e.id:void 0},y=function(t,n){var r=!1,e=!1,i=function(){return e=!0},u=function(){return r=!0,i()};return i=t.dispatcher.subscribe(function(e){return f(t,function(){if(!r){if(n(e)===E.noMore)return u()}})}),e&&i(),u};return{whenDoneWith:h,hasWaiters:function(){return i.length>0},inTransaction:d,currentEventId:b,wrappedSubscribe:y,afterTransaction:f}}();I(t.prototype,{_isSource:!0,subscribe:function(t){return this.obs.dispatcher.subscribe(t)},toString:function(){return this.obs.toString()},markEnded:function(){return this.ended=!0,!0},consume:function(){return this.lazy?{value:_.always(this.queue[0])}:this.queue[0]},push:function(t){return this.queue=[t],[t]},mayHave:function(){return!0},hasAtLeast:function(){return this.queue.length},flatten:!0}),x(n,t),I(n.prototype,{consume:function(){return this.queue.shift()},push:function(t){return this.queue.push(t)},mayHave:function(t){return!this.ended||this.queue.length>=t},hasAtLeast:function(t){return this.queue.length>=t},flatten:!1}),x(r,t),I(r.prototype,{consume:function(){var t=this.queue;return this.queue=[],{value:function(){return t}}},push:function(t){return this.queue.push(t.value())},hasAtLeast:function(){return!0}}),t.isTrigger=function(t){return(null!=t?t._isSource:void 0)?t.sync:null!=t?t._isEventStream:void 0},t.fromObservable=function(r){return(null!=r?r._isSource:void 0)?r:(null!=r?r._isProperty:void 0)?new t(r,!1):new n(r,!0)},I(e.prototype,{_isDesc:!0,deps:function(){return this.cached||(this.cached=B([this.context].concat(this.args))),this.cached},toString:function(){return _.toString(this.context)+"."+_.toString(this.method)+"("+_.map(_.toString,this.args)+")"}});var V=function(t,n){var r=t||n;if(r&&r._isDesc)return t||n;for(var i=arguments.length,u=Array(i>2?i-2:0),o=2;o<i;o++)u[o-2]=arguments[o];return new e(t,n,u)},H=function(t,n){return n.desc=t,n},B=function(t){return M(t)?_.flatMap(B,t):k(t)?[t]:(void 0!==t&&null!==t?t._isSource:void 0)?[t.obs]:[]};E.Desc=e,E.Desc.empty=new E.Desc("","",[]);var F=function(t){return function(n){for(var r=arguments.length,e=Array(r>1?r-1:0),i=1;i<r;i++)e[i-1]=arguments[i];if("object"==typeof n&&e.length){var u=n,o=e[0];n=function(){return u[o].apply(u,arguments)},e=e.slice(1)}return t.apply(void 0,[n].concat(e))}},C=function(t){return t=Array.prototype.slice.call(t),j.apply(void 0,t)},N=function(t,n){return function(){for(var r=arguments.length,e=Array(r),i=0;i<r;i++)e[i]=arguments[i];return t.apply(void 0,n.concat(e))}},q=function(t){return function(n){return function(r){if(void 0!==r&&null!==r){var e=r[n];return _.isFunction(e)?e.apply(r,t):e}}}},L=function(t,n){var r=t.slice(1).split("."),e=_.map(q(n),r);return function(t){for(var n,r=0;r<e.length;r++)n=e[r],t=n(t);return t}},U=function(t){return"string"==typeof t&&t.length>1&&"."===t.charAt(0)},j=F(function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return _.isFunction(t)?r.length?N(t,r):t:U(t)?L(t,r):_.always(t)}),z=function(t,n){return j.apply(void 0,[t].concat(n))},Q=function(t,n,r,e){if(void 0!==n&&null!==n?n._isProperty:void 0){var i=n.sampledBy(t,function(t,n){return[t,n]});return e.call(i,function(t){var n=t[0];t[1];return n}).map(function(t){t[0];return t[1]})}return n=z(n,r),e.call(t,n)},R=function(t){if(_.isFunction(t))return t;if(U(t)){var n=$(t);return function(t,r){return t[n](r)}}throw new S("not a function or a field key: "+t)},$=function(t){return t.slice(1)};I(i.prototype,{_isSome:!0,getOrElse:function(){return this.value},get:function(){return this.value},filter:function(t){return t(this.value)?new i(this.value):Z},map:function(t){return new i(t(this.value))},forEach:function(t){return t(this.value)},isDefined:!0,toArray:function(){return[this.value]},inspect:function(){return"Some("+this.value+")"},toString:function(){return this.inspect()}});var Z={_isNone:!0,getOrElse:function(t){return t},filter:function(){return Z},map:function(){return Z},forEach:function(){},isDefined:!1,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}},X=function(t){return(void 0!==t&&null!==t?t._isSome:void 0)||(void 0!==t&&null!==t?t._isNone:void 0)?t:new i(t)};E.noMore="<no-more>",E.more="<more>";var G=0;u.prototype._isEvent=!0,u.prototype.isEvent=function(){return!0},u.prototype.isEnd=function(){return!1},u.prototype.isInitial=function(){return!1},u.prototype.isNext=function(){return!1},u.prototype.isError=function(){return!1},u.prototype.hasValue=function(){return!1},u.prototype.filter=function(){return!0},u.prototype.inspect=function(){return this.toString()},u.prototype.log=function(){return this.toString()},x(o,u),o.prototype.isNext=function(){return!0},o.prototype.hasValue=function(){return!0},o.prototype.value=function(){var t;return(null!=(t=this.valueF)?t._isNext:void 0)?(this.valueInternal=this.valueF.value(),this.valueF=void 0):this.valueF&&(this.valueInternal=this.valueF(),this.valueF=void 0),this.valueInternal},o.prototype.fmap=function(t){var n,r;return this.valueInternal?(r=this.valueInternal,this.apply(function(){return t(r)})):(n=this,this.apply(function(){return t(n.value())}))},o.prototype.apply=function(t){return new o(t)},o.prototype.filter=function(t){return t(this.value())},o.prototype.toString=function(){return _.toString(this.value())},o.prototype.log=function(){return this.value()},o.prototype._isNext=!0,x(s,o),s.prototype._isInitial=!0,s.prototype.isInitial=function(){return!0},s.prototype.isNext=function(){return!1},s.prototype.apply=function(t){return new s(t)},s.prototype.toNext=function(){return new o(this)},x(c,u),c.prototype.isEnd=function(){return!0},c.prototype.fmap=function(){return this},c.prototype.apply=function(){return this},c.prototype.toString=function(){return"<end>"},x(a,u),a.prototype.isError=function(){return!0},a.prototype.fmap=function(){return this},a.prototype.apply=function(){return this},a.prototype.toString=function(){return"<error> "+_.toString(this.error)},E.Event=u,E.Initial=s,E.Next=o,E.End=c,E.Error=a;var J=function(t){return new s(t,!0)},K=function(t){return new o(t,!0)},Y=function(){return new c},tt=function(t){return t&&t._isEvent?t:K(t)},nt=0,rt=function(){};I(f.prototype,{_isObservable:!0,subscribe:function(t){return T.wrappedSubscribe(this,t)},subscribeInternal:function(t){return this.dispatcher.subscribe(t)},onValue:function(){var t=C(arguments);return this.subscribe(function(n){if(n.hasValue())return t(n.value())})},onValues:function(t){return this.onValue(function(n){return t.apply(void 0,n)})},onError:function(){var t=C(arguments);return this.subscribe(function(n){if(n.isError())return t(n.error)})},onEnd:function(){var t=C(arguments);return this.subscribe(function(n){if(n.isEnd())return t()})},name:function(t){return this._name=t,this},withDescription:function(){return this.desc=V.apply(void 0,arguments),this},toString:function(){return this._name?this._name:this.desc.toString()},deps:function(){return this.desc.deps()},internalDeps:function(){return this.initialDesc.deps()}}),f.prototype.assign=f.prototype.onValue,f.prototype.forEach=f.prototype.onValue,f.prototype.inspect=f.prototype.toString,E.Observable=f,I(h.prototype,{add:function(t){var n=this;if(!this.unsubscribed){var r=!1,e=D;this.starting.push(t);var i=function(){if(!n.unsubscribed)return r=!0,n.remove(e),_.remove(t,n.starting)};return e=t(this.unsubscribe,i),this.unsubscribed||r?e():this.subscriptions.push(e),_.remove(t,this.starting),e}},remove:function(t){if(!this.unsubscribed)return void 0!==_.remove(t,this.subscriptions)?t():void 0},unsubscribe:function(){if(!this.unsubscribed){this.unsubscribed=!0;for(var t=this.subscriptions,n=0;n<t.length;n++)t[n]();return this.subscriptions=[],this.starting=[],[]}},count:function(){return this.unsubscribed?0:this.subscriptions.length+this.starting.length},empty:function(){return 0===this.count()}}),E.CompositeUnsubscribe=h,l.prototype.hasSubscribers=function(){return this.subscriptions.length>0},l.prototype.removeSub=function(t){return this.subscriptions=_.without(t,this.subscriptions),this.subscriptions},l.prototype.push=function(t){return t.isEnd()&&(this.ended=!0),T.inTransaction(t,this,this.pushIt,[t])},l.prototype.pushToSubscriptions=function(t){try{for(var n=this.subscriptions,r=n.length,e=0;e<r;e++){var i=n[e];(i.sink(t)===E.noMore||t.isEnd())&&this.removeSub(i)}return!0}catch(t){throw this.pushing=!1,this.queue=[],t}},l.prototype.pushIt=function(t){if(this.pushing)return this.queue.push(t),E.more;if(t!==this.prevError){for(t.isError()&&(this.prevError=t),this.pushing=!0,this.pushToSubscriptions(t),this.pushing=!1;this.queue.length;)t=this.queue.shift(),this.push(t);return this.hasSubscribers()?E.more:(this.unsubscribeFromSource(),E.noMore)}},l.prototype.handleEvent=function(t){return this._handleEvent?this._handleEvent(t):this.push(t)},l.prototype.unsubscribeFromSource=function(){this.unsubSrc&&this.unsubSrc(),this.unsubSrc=void 0},l.prototype.subscribe=function(t){var n;return this.ended?(t(Y()),D):(n={sink:t},this.subscriptions.push(n),1===this.subscriptions.length&&(this.unsubSrc=this._subscribe(this.handleEvent)),function(t){return function(){if(t.removeSub(n),!t.hasSubscribers())return t.unsubscribeFromSource()}}(this))},E.Dispatcher=l,x(p,f),I(p.prototype,{_isEventStream:!0,toProperty:function(t){var n=0===arguments.length?Z:X(function(){return t}),r=this.dispatcher;return new d(new E.Desc(this,"toProperty",[t]),function(t){var e=!1,u=!1,o=D,c=E.more,a=function(){if(!e)return n.forEach(function(n){if(e=!0,(c=t(new s(n)))===E.noMore)return o(),o=D,D})};return o=r.subscribe(function(r){return r.hasValue()?r.isInitial()&&!u?(n=new i(function(){return r.value()}),E.more):(r.isInitial()||a(),e=!0,n=new i(r),t(r)):(r.isEnd()&&(c=a()),c!==E.noMore?t(r):void 0)}),u=!0,a(),o})},toEventStream:function(){return this},withHandler:function(t){return new p(new E.Desc(this,"withHandler",[t]),this.dispatcher.subscribe,t)}}),E.EventStream=p,E.never=function(){return new p(V(E,"never"),function(t){return t(Y()),D})},E.when=function(){if(0===arguments.length)return E.never();for(var n=arguments.length,r=[],e=[],i=0,u=[];i<n;){u[i]=arguments[i],u[i+1]=arguments[i+1];for(var o,s=_.toArray(arguments[i]),c=it(arguments[i+1]),a={f:c,ixs:[]},f=!1,h=0;h<s.length;h++){o=s[h];var l=_.indexOf(r,o);f||(f=t.isTrigger(o)),l<0&&(r.push(o),l=r.length-1);for(var v,d=0;d<a.ixs.length;d++)v=a.ixs[d],v.index===l&&v.count++;a.ixs.push({index:l,count:1})}s.length>0&&e.push(a),i+=2}if(!r.length)return E.never();r=_.map(t.fromObservable,r);var b=_.any(r,function(t){return t.flatten})&&et(_.map(function(t){return t.obs},r)),y=new E.Desc(E,"when",u),m=new p(y,function(t){var n=[],i=!1,u=function(t){for(var n,e=0;e<t.ixs.length;e++)if(n=t.ixs[e],!r[n.index].hasAtLeast(n.count))return!1;return!0},o=function(t){return!t.sync||t.ended},s=function(t){for(var n,e=0;e<t.ixs.length;e++)if(n=t.ixs[e],!r[n.index].mayHave(n.count))return!0},c=function(t){return!t.source.flatten},a=function(a){return function(f){var h=function(){return T.whenDoneWith(m,p)},l=function(){if(!(n.length>0))return E.more;for(var i,o=E.more,s=n.pop(),a=0;a<e.length;a++)if(i=e[a],u(i)){var f=function(){for(var t,n=[],e=0;e<i.ixs.length;e++)t=i.ixs[e],n.push(r[t.index].consume());return n}();return o=t(s.e.apply(function(){var t,n=function(){for(var t,n=[],r=0;r<f.length;r++)t=f[r],n.push(t.value());return n}();return(t=i).f.apply(t,n)})),n.length&&(n=_.filter(c,n)),o===E.noMore?o:l()}},p=function(){var n=l();return i&&(_.all(r,o)||_.all(e,s))&&(n=E.noMore,t(Y())),n===E.noMore&&f(),n};return a.subscribe(function(r){if(r.isEnd())i=!0,a.markEnded(),h();else if(r.isError())var e=t(r);else a.push(r),a.sync&&(n.push({source:a,e:r}),b||T.hasWaiters()?h():p());return e===E.noMore&&f(),e||E.more})}};return new E.CompositeUnsubscribe(function(){for(var t,n=[],e=0;e<r.length;e++)t=r[e],n.push(a(t));return n}()).unsubscribe});return m};var et=function(t){var n=arguments.length<=1||void 0===arguments[1]?[]:arguments[1],r=function(t){if(_.contains(n,t))return!0;var e=t.internalDeps();return e.length?(n.push(t),_.any(e,r)):(n.push(t),!1)};return _.any(t,r)},it=function(t){return _.isFunction(t)?t:_.always(t)};E.groupSimultaneous=function(){for(var t=arguments.length,n=Array(t),e=0;e<t;e++)n[e]=arguments[e];1===n.length&&M(n[0])&&(n=n[0]);var i=function(){for(var t,e=[],i=0;i<n.length;i++)t=n[i],e.push(new r(t));return e}();return H(new E.Desc(E,"groupSimultaneous",n),E.when(i,function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n}))},x(v,l),I(v.prototype,{push:function(t){return t.isEnd()&&(this.propertyEnded=!0),t.hasValue()&&(this.current=new i(t),this.currentValueRootId=T.currentEventId()),l.prototype.push.call(this,t)},maybeSubSource:function(t,n){return n===E.noMore?D:this.propertyEnded?(t(Y()),D):l.prototype.subscribe.call(this,t)},subscribe:function(t){var n=this,r=E.more;if(this.current.isDefined&&(this.hasSubscribers()||this.propertyEnded)){var e=T.currentEventId(),i=this.currentValueRootId;return!this.propertyEnded&&i&&e&&e!==i?(T.whenDoneWith(this.property,function(){if(n.currentValueRootId===i)return t(J(n.current.get().value()))}),this.maybeSubSource(t,r)):(T.inTransaction(void 0,this,function(){return r=t(J(this.current.get().value()))},[]),this.maybeSubSource(t,r))}return this.maybeSubSource(t,r)}}),x(d,f),I(d.prototype,{_isProperty:!0,changes:function(){var t=this;return new p(new E.Desc(this,"changes",[]),function(n){return t.dispatcher.subscribe(function(t){if(!t.isInitial())return n(t)})})},withHandler:function(t){return new d(new E.Desc(this,"withHandler",[t]),this.dispatcher.subscribe,t)},toProperty:function(){return this},toEventStream:function(){var t=this;return new p(new E.Desc(this,"toEventStream",[]),function(n){return t.dispatcher.subscribe(function(t){return t.isInitial()&&(t=t.toNext()),n(t)})})}}),E.Property=d,E.constant=function(t){return new d(new E.Desc(E,"constant",[t]),function(n){return n(J(t)),n(Y()),D})},E.fromBinder=function(t){var n=arguments.length<=1||void 0===arguments[1]?_.id:arguments[1];return new p(new E.Desc(E,"fromBinder",[t,n]),function(r){var e=!1,i=!1,u=function(){if(!e)return void 0!==o&&null!==o?(o(),e=!0):i=!0},o=t(function(){for(var t,e=arguments.length,i=Array(e),o=0;o<e;o++)i[o]=arguments[o];var s=n.apply(this,i);M(s)&&(null!=(t=_.last(s))?t._isEvent:void 0)||(s=[s]);for(var c,a=E.more,f=0;f<s.length;f++)if(c=s[f],(a=r(c=tt(c)))===E.noMore||c.isEnd())return u(),a;return a});return i&&u(),u})},E.Observable.prototype.map=function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return Q(this,t,r,function(t){return H(new E.Desc(this,"map",[t]),this.withHandler(function(n){return this.push(n.fmap(t))}))})};var ut=function(t){return M(t[0])?t[0]:Array.prototype.slice.call(t)},ot=function(t){return _.isFunction(t[0])?[ut(Array.prototype.slice.call(t,1)),t[0]]:[ut(Array.prototype.slice.call(t,0,t.length-1)),_.last(t)]};E.combineAsArray=function(){var n=ut(arguments);if(n.length){for(var r=[],e=0;e<n.length;e++){var i=k(n[e])?n[e]:E.constant(n[e]);r.push(new t(i,!0))}return H(new E.Desc(E,"combineAsArray",n),E.when(r,function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n}).toProperty())}return E.constant([])},E.onValues=function(){return E.combineAsArray(Array.prototype.slice.call(arguments,0,arguments.length-1)).onValues(arguments[arguments.length-1])},E.combineWith=function(){var t=ot(arguments),n=t[0],r=t[1],e=new E.Desc(E,"combineWith",[r].concat(n));return H(e,E.combineAsArray(n).map(function(t){return r.apply(void 0,t)}))},E.Observable.prototype.combine=function(t,n){var r=R(n),e=new E.Desc(this,"combine",[t,n]);return H(e,E.combineAsArray(this,t).map(function(t){return r(t[0],t[1])}))},E.Observable.prototype.withStateMachine=function(t,n){var r=t,e=new E.Desc(this,"withStateMachine",[t,n]);return H(e,this.withHandler(function(t){var e=n(r,t),i=e[0],u=e[1];r=i;for(var o,s=E.more,c=0;c<u.length;c++)if(o=u[c],(s=this.push(o))===E.noMore)return s;return s}))};var st=function(t,n){return t===n},ct=function(t){return void 0!==t&&null!==t&&t._isNone};E.Observable.prototype.skipDuplicates=function(){var t=arguments.length<=0||void 0===arguments[0]?st:arguments[0],n=new E.Desc(this,"skipDuplicates",[]);return H(n,this.withStateMachine(Z,function(n,r){return r.hasValue()?r.isInitial()||ct(n)||!t(n.get(),r.value())?[new i(r.value()),[r]]:[n,[]]:[n,[r]]}))},E.Observable.prototype.awaiting=function(t){var n=new E.Desc(this,"awaiting",[t]);return H(n,E.groupSimultaneous(this,t).map(function(t){return 0===t[1].length}).toProperty(!1).skipDuplicates())},E.Observable.prototype.not=function(){return H(new E.Desc(this,"not",[]),this.map(function(t){return!t}))},E.Property.prototype.and=function(t){return H(new E.Desc(this,"and",[t]),this.combine(t,function(t,n){return t&&n}))},E.Property.prototype.or=function(t){return H(new E.Desc(this,"or",[t]),this.combine(t,function(t,n){return t||n}))},E.scheduler={setTimeout:function(t,n){return setTimeout(t,n)},setInterval:function(t,n){return setInterval(t,n)},clearInterval:function(t){return clearInterval(t)},clearTimeout:function(t){return clearTimeout(t)},now:function(){return(new Date).getTime()}},E.EventStream.prototype.bufferWithTime=function(t){return H(new E.Desc(this,"bufferWithTime",[t]),this.bufferWithTimeOrCount(t,Number.MAX_VALUE))},E.EventStream.prototype.bufferWithCount=function(t){return H(new E.Desc(this,"bufferWithCount",[t]),this.bufferWithTimeOrCount(void 0,t))},E.EventStream.prototype.bufferWithTimeOrCount=function(t,n){var r=function(r){return r.values.length===n?r.flush():void 0!==t?r.schedule():void 0},e=new E.Desc(this,"bufferWithTimeOrCount",[t,n]);return H(e,this.buffer(t,r,r))},E.EventStream.prototype.buffer=function(t){var n=arguments.length<=1||void 0===arguments[1]?D:arguments[1],r=arguments.length<=2||void 0===arguments[2]?D:arguments[2],e={scheduled:null,end:void 0,values:[],flush:function(){if(this.scheduled&&(E.scheduler.clearTimeout(this.scheduled),this.scheduled=null),this.values.length>0){var t=this.values;this.values=[];var n=this.push(K(t));if(null!=this.end)return this.push(this.end);if(n!==E.noMore)return r(this)}else if(null!=this.end)return this.push(this.end)},schedule:function(){var n=this;if(!this.scheduled)return this.scheduled=t(function(){return n.flush()})}},i=E.more;if(!_.isFunction(t)){var u=t;t=function(t){return E.scheduler.setTimeout(t,u)}}return H(new E.Desc(this,"buffer",[]),this.withHandler(function(t){var r=this;return e.push=function(t){return r.push(t)},t.isError()?i=this.push(t):t.isEnd()?(e.end=t,e.scheduled||e.flush()):(e.values.push(t.value()),n(e)),i}))},E.Observable.prototype.filter=function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return Q(this,t,r,function(t){return H(new E.Desc(this,"filter",[t]),this.withHandler(function(n){return n.filter(t)?this.push(n):E.more}))})},E.once=function(t){return new p(new e(E,"once",[t]),function(n){return n(tt(t)),n(Y()),D})},E.EventStream.prototype.concat=function(t){var n=this;return new p(new E.Desc(n,"concat",[t]),function(r){var e=D,i=n.dispatcher.subscribe(function(n){return n.isEnd()?e=t.toEventStream().dispatcher.subscribe(r):r(n)});return function(){return i(),e()}})},E.Property.prototype.concat=function(t){return b(this,this.changes().concat(t))},E.concatAll=function(){var t=ut(arguments);return t.length?H(new E.Desc(E,"concatAll",t),_.fold(_.tail(t),_.head(t).toEventStream(),function(t,n){return t.concat(n)})):E.never()},E.Observable.prototype.flatMap=function(){return ht(this,at(arguments))},E.Observable.prototype.flatMapFirst=function(){return ht(this,at(arguments),!0)};var at=function(t){return 1===t.length&&k(t[0])?_.always(t[0]):C(t)},ft=function(t){return k(t)?t:E.once(t)},ht=function(t,n,r,e){var i=[t],u=[],o=new E.Desc(t,"flatMap"+(r?"First":""),[n]),s=new p(o,function(i){var o=new h,s=[],c=function(t){var r=ft(n(t.value()));return u.push(r),o.add(function(t,n){return r.dispatcher.subscribe(function(e){if(e.isEnd())return _.remove(r,u),a(),f(n),E.noMore;(void 0!==e&&null!==e?e._isInitial:void 0)&&(e=e.toNext());var o=i(e);return o===E.noMore&&t(),o})})},a=function(){var t=s.shift();if(t)return c(t)},f=function(t){if(t(),o.empty())return i(Y())};return o.add(function(n,u){return t.dispatcher.subscribe(function(t){return t.isEnd()?f(u):t.isError()?i(t):r&&o.count()>1?E.more:o.unsubscribed?E.noMore:e&&o.count()>e?s.push(t):c(t)})}),o.unsubscribe});return s.internalDeps=function(){return u.length?i.concat(u):i},s};E.Observable.prototype.flatMapWithConcurrencyLimit=function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];var i=new E.Desc(this,"flatMapWithConcurrencyLimit",[t].concat(r));return H(i,ht(this,at(r),!1,t))},E.Observable.prototype.flatMapConcat=function(){var t=new E.Desc(this,"flatMapConcat",Array.prototype.slice.call(arguments,0));return H(t,this.flatMapWithConcurrencyLimit.apply(this,[1].concat(w.call(arguments))))},E.later=function(t,n){return H(new E.Desc(E,"later",[t,n]),E.fromBinder(function(r){var e=function(){return r([n,Y()])},i=E.scheduler.setTimeout(e,t);return function(){return E.scheduler.clearTimeout(i)}}))},E.Observable.prototype.bufferingThrottle=function(t){var n=new E.Desc(this,"bufferingThrottle",[t]);return H(n,this.flatMapConcat(function(n){return E.once(n).concat(E.later(t).filter(!1))}))},E.Property.prototype.bufferingThrottle=function(){return E.Observable.prototype.bufferingThrottle.apply(this,arguments).toProperty()},x(y,p),I(y.prototype,{unsubAll:function(){for(var t,n=this.subscriptions,r=0;r<n.length;r++)t=n[r],"function"==typeof t.unsub&&t.unsub()},subscribeAll:function(t){if(this.ended)t(Y());else{this.sink=t;for(var n,r=O(this.subscriptions),e=0;e<r.length;e++)n=r[e],this.subscribeInput(n)}return this.unsubAll},guardedSink:function(t){var n=this;return function(r){return r.isEnd()?(n.unsubscribeInput(t),E.noMore):n.sink(r)}},subscribeInput:function(t){return t.unsub=t.input.dispatcher.subscribe(this.guardedSink(t.input)),t.unsub},unsubscribeInput:function(t){for(var n,r=this.subscriptions,e=0;e<r.length;e++)if(n=r[e],n.input===t)return"function"==typeof n.unsub&&n.unsub(),void this.subscriptions.splice(e,1)},plug:function(t){var n=this;if(!this.ended){var r={input:t};return this.subscriptions.push(r),void 0!==this.sink&&this.subscribeInput(r),function(){return n.unsubscribeInput(t)}}},end:function(){if(this.ended=!0,this.unsubAll(),"function"==typeof this.sink)return this.sink(Y())},push:function(t){if(!this.ended&&"function"==typeof this.sink){var n=!this.pushing;if(!n)return this.pushQueue||(this.pushQueue=[]),void this.pushQueue.push(t);this.pushing=!0;try{return this.sink(K(t))}finally{if(n&&this.pushQueue){for(var r=0;r<this.pushQueue.length;){var t=this.pushQueue[r];this.sink(K(t)),r++}this.pushQueue=null}this.pushing=!1}}},error:function(t){if("function"==typeof this.sink)return this.sink(new a(t))}}),E.Bus=y;var lt=function(t,n){return F(function(r){for(var e=N(n,[function(t,n){return r.apply(void 0,t.concat([n]))}]),i=arguments.length,u=Array(i>1?i-1:0),o=1;o<i;o++)u[o-1]=arguments[o];return H(new E.Desc(E,t,[r].concat(u)),E.combineAsArray(u).flatMap(e))})};E.fromCallback=lt("fromCallback",function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return E.fromBinder(function(n){return z(t,r)(n),D},function(t){return[t,Y()]})}),E.fromNodeCallback=lt("fromNodeCallback",function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return E.fromBinder(function(n){return z(t,r)(n),D},function(t,n){return t?[new a(t),Y()]:[n,Y()]})}),E.combineTemplate=function(t){function n(t){return t[t.length-1]}function r(t,r,e){return n(t)[r]=e,e}function e(t,n){return function(e,i){r(e,t,i[n])}}function i(t,n){return function(e){r(e,t,n)}}function u(t){return M(t)?[]:{}}function o(t,n){return function(e){var i=u(n);r(e,t,i),e.push(i)}}function s(t){if(k(t))return!0;if(t&&(t.constructor==Object||t.constructor==Array))for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var r=t[n];if(s(r))return!0}}function c(t,n){if(k(n))l.push(n),h.push(e(t,l.length-1));else if(s(n)){var r=function(t){t.pop()};h.push(o(t,n)),f(n),h.push(r)}else h.push(i(t,n))}function a(n){for(var r=u(t),e=[r],i=0;i<h.length;i++)(0,h[i])(e,n);return r}function f(t){_.each(t,c)}var h=[],l=[],p=s(t)?(f(t),E.combineAsArray(l).map(a)):E.constant(t);return H(new E.Desc(E,"combineTemplate",[t]),p)},E.Observable.prototype.mapEnd=function(){var t=C(arguments);return H(new E.Desc(this,"mapEnd",[t]),this.withHandler(function(n){return n.isEnd()?(this.push(K(t(n))),this.push(Y()),E.noMore):this.push(n)}))},E.Observable.prototype.skipErrors=function(){return H(new E.Desc(this,"skipErrors",[]),this.withHandler(function(t){return t.isError()?E.more:this.push(t)}))},E.Observable.prototype.takeUntil=function(t){var n={},r=E.groupSimultaneous(this.mapEnd(n),t.skipErrors());this instanceof d&&(r=r.toProperty());var e=r.withHandler(function(t){if(t.hasValue()){var r=t.value(),e=r[0];if(r[1].length)return this.push(Y());for(var i,u=E.more,o=0;o<e.length;o++)i=e[o],u=i===n?this.push(Y()):this.push(K(i));return u}return this.push(t)});return H(new E.Desc(this,"takeUntil",[t]),e)},E.Observable.prototype.flatMapLatest=function(){var t=at(arguments),n=this.toEventStream();return H(new E.Desc(this,"flatMapLatest",[t]),n.flatMap(function(r){return ft(t(r)).takeUntil(n)}))},E.Property.prototype.delayChanges=function(t,n){return H(t,b(this,n(this.changes())))},
E.EventStream.prototype.delayChanges=function(t,n){return H(t,n(this))},E.Observable.prototype.delay=function(t){return this.delayChanges(new E.Desc(this,"delay",[t]),function(n){return n.flatMap(function(n){return E.later(t,n)})})},E.Observable.prototype.debounce=function(t){return this.delayChanges(new E.Desc(this,"debounce",[t]),function(n){return n.flatMapLatest(function(n){return E.later(t,n)})})},E.Observable.prototype.debounceImmediate=function(t){return this.delayChanges(new E.Desc(this,"debounceImmediate",[t]),function(n){return n.flatMapFirst(function(n){return E.once(n).concat(E.later(t).filter(!1))})})},E.Observable.prototype.decode=function(t){return H(new E.Desc(this,"decode",[t]),this.combine(E.combineTemplate(t),function(t,n){return n[t]}))},E.Observable.prototype.scan=function(t,n){var r,e=this;n=R(n);var u=X(t),o=!1,c=function(t){var c=!1,a=D,f=E.more,h=function(){if(!c)return u.forEach(function(n){if(c=o=!0,(f=t(new s(function(){return n})))===E.noMore)return a(),a=D})};return a=e.dispatcher.subscribe(function(r){if(r.hasValue()){if(o&&r.isInitial())return E.more;r.isInitial()||h(),c=o=!0;var e=u.getOrElse(void 0),s=n(e,r.value());return u=new i(s),t(r.apply(function(){return s}))}if(r.isEnd()&&(f=h()),f!==E.noMore)return t(r)}),T.whenDoneWith(r,h),a};return r=new d(new E.Desc(this,"scan",[t,n]),c)},E.Observable.prototype.diff=function(t,n){return n=R(n),H(new E.Desc(this,"diff",[t,n]),this.scan([t],function(t,r){return[r,n(t[0],r)]}).filter(function(t){return 2===t.length}).map(function(t){return t[1]}))},E.Observable.prototype.doAction=function(){var t=C(arguments);return H(new E.Desc(this,"doAction",[t]),this.withHandler(function(n){return n.hasValue()&&t(n.value()),this.push(n)}))},E.Observable.prototype.doEnd=function(){var t=C(arguments);return H(new E.Desc(this,"doEnd",[t]),this.withHandler(function(n){return n.isEnd()&&t(),this.push(n)}))},E.Observable.prototype.doError=function(){var t=C(arguments);return H(new E.Desc(this,"doError",[t]),this.withHandler(function(n){return n.isError()&&t(n.error),this.push(n)}))},E.Observable.prototype.doLog=function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return H(new E.Desc(this,"doLog",n),this.withHandler(function(t){return"undefined"!=typeof console&&null!==console&&"function"==typeof console.log&&console.log.apply(console,n.concat([t.log()])),this.push(t)}))},E.Observable.prototype.endOnError=function(t){void 0!==t&&null!==t||(t=!0);for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return Q(this,t,r,function(t){return H(new E.Desc(this,"endOnError",[]),this.withHandler(function(n){return n.isError()&&t(n.error)?(this.push(n),this.push(Y())):this.push(n)}))})},f.prototype.errors=function(){return H(new E.Desc(this,"errors",[]),this.filter(function(){return!1}))},E.Observable.prototype.take=function(t){return t<=0?E.never():H(new E.Desc(this,"take",[t]),this.withHandler(function(n){return n.hasValue()?(t--,t>0?this.push(n):(0===t&&this.push(n),this.push(Y()),E.noMore)):this.push(n)}))},E.Observable.prototype.first=function(){return H(new E.Desc(this,"first",[]),this.take(1))},E.Observable.prototype.mapError=function(){var t=C(arguments);return H(new E.Desc(this,"mapError",[t]),this.withHandler(function(n){return n.isError()?this.push(K(t(n.error))):this.push(n)}))},E.Observable.prototype.flatMapError=function(t){var n=new E.Desc(this,"flatMapError",[t]);return H(n,this.mapError(function(t){return new a(t)}).flatMap(function(n){return n instanceof a?t(n.error):E.once(n)}))},E.EventStream.prototype.flatScan=function(t,n){var r=t;return this.flatMapConcat(function(t){return ft(n(r,t)).doAction(function(t){return r=t})}).toProperty(t)},E.EventStream.prototype.sampledBy=function(t,n){return H(new E.Desc(this,"sampledBy",[t,n]),this.toProperty().sampledBy(t,n))},E.Property.prototype.sampledBy=function(n,r){var e=!1;void 0!==r&&null!==r?r=R(r):(e=!0,r=function(t){return t.value()});var i=new t(this,!1,e),u=new t(n,!0,e),o=E.when([i,u],r),s=n._isProperty?o.toProperty():o;return H(new E.Desc(this,"sampledBy",[n,r]),s)},E.Property.prototype.sample=function(t){return H(new E.Desc(this,"sample",[t]),this.sampledBy(E.interval(t,{})))},E.Observable.prototype.map=function(t){if(t&&t._isProperty)return t.sampledBy(this,A);for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return Q(this,t,r,function(t){return H(new E.Desc(this,"map",[t]),this.withHandler(function(n){return this.push(n.fmap(t))}))})},E.Observable.prototype.fold=function(t,n){return H(new E.Desc(this,"fold",[t,n]),this.scan(t,n).sampledBy(this.filter(!1).mapEnd().toProperty()))},f.prototype.reduce=f.prototype.fold;var pt=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"],["bind","unbind"]],vt=function(t){for(var n,r=0;r<pt.length;r++){n=pt[r];var e=[t[n[0]],t[n[1]]];if(e[0]&&e[1])return e}for(var i=0;i<pt.length;i++){n=pt[i];var u=t[n[0]];if(u)return[u,function(){}]}throw new a("No suitable event methods in "+t)};E.fromEventTarget=function(t,n,r){var e=vt(t),i=e[0],u=e[1],o=new E.Desc(E,"fromEvent",[t,n]);return H(o,E.fromBinder(function(r){return i.call(t,n,r),function(){return u.call(t,n,r)}},r))},E.fromEvent=E.fromEventTarget,E.fromPoll=function(t,n){var r=new E.Desc(E,"fromPoll",[t,n]);return H(r,E.fromBinder(function(n){var r=E.scheduler.setInterval(n,t);return function(){return E.scheduler.clearInterval(r)}},n))},E.fromPromise=function(t,n){var r=arguments.length<=2||void 0===arguments[2]?m:arguments[2];return H(new E.Desc(E,"fromPromise",[t]),E.fromBinder(function(r){var e=t.then(r,function(t){return r(new a(t))});return e&&"function"==typeof e.done&&e.done(),n?function(){if("function"==typeof t.abort)return t.abort()}:function(){}},r))},E.Observable.prototype.groupBy=function(t){var n=arguments.length<=1||void 0===arguments[1]?E._.id:arguments[1],r={},e=this;return e.filter(function(n){return!r[t(n)]}).map(function(i){var u=t(i),o=e.filter(function(n){return t(n)===u}),s=E.once(i).concat(o),c=n(s,i).withHandler(function(t){if(this.push(t),t.isEnd())return delete r[u]});return r[u]=c,c})},E.fromArray=function(t){if(t.length){var n=0,r=new p(new E.Desc(E,"fromArray",[t]),function(e){function i(){if(c=!0,!s){for(s=!0;c;)if(c=!1,o!==E.noMore&&!u){var a=t[n++];o=e(tt(a)),o!==E.noMore&&(n===t.length?e(Y()):T.afterTransaction(r,i))}return s=!1}}var u=!1,o=E.more,s=!1,c=!1;return i(),function(){return u=!0}});return r}return H(new E.Desc(E,"fromArray",t),E.never())},E.EventStream.prototype.holdWhen=function(t){var n=!1,r=[],e=this,i=!1;return new p(new E.Desc(this,"holdWhen",[t]),function(u){var o=new h,s=!1,c=function(t){if("function"==typeof t&&t(),o.empty()&&s)return u(Y())};return o.add(function(e,o){return t.subscribeInternal(function(t){if(!t.hasValue())return t.isEnd()?c(o):u(t);if(!(n=t.value())){var e=r;return r=[],function(){for(var t,n=[],r=0;r<e.length;r++)t=e[r],n.push(u(K(t)));return i&&(n.push(u(Y())),o()),n}()}})}),o.add(function(t,o){return e.subscribeInternal(function(t){return n&&t.hasValue()?r.push(t.value()):t.isEnd()&&r.length?(i=!0,c(o)):u(t)})}),s=!0,c(),o.unsubscribe})},E.interval=function(t){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return H(new E.Desc(E,"interval",[t,n]),E.fromPoll(t,function(){return K(n)}))},E.$={},E.$.asEventStream=function(t,n,r){var e=this;return _.isFunction(n)&&(r=n,n=void 0),H(new E.Desc(this.selector||this,"asEventStream",[t]),E.fromBinder(function(r){return e.on(t,n,r),function(){return e.off(t,n,r)}},r))},"undefined"!=typeof jQuery&&jQuery&&(jQuery.fn.asEventStream=E.$.asEventStream),"undefined"!=typeof Zepto&&Zepto&&(Zepto.fn.asEventStream=E.$.asEventStream),E.Observable.prototype.last=function(){var t;return H(new E.Desc(this,"last",[]),this.withHandler(function(n){if(n.isEnd())return t&&this.push(t),this.push(Y()),E.noMore;t=n}))},E.Observable.prototype.log=function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.subscribe(function(t){"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,n.concat([t.log()]))}),this},E.EventStream.prototype.merge=function(t){var n=this;return H(new E.Desc(n,"merge",[t]),E.mergeAll(this,t))},E.mergeAll=function(){var t=ut(arguments);return t.length?new p(new E.Desc(E,"mergeAll",t),function(n){var r=0,e=function(e){return function(i){return e.dispatcher.subscribe(function(e){if(e.isEnd())return r++,r===t.length?n(Y()):E.more;var u=n(e);return u===E.noMore&&i(),u})}},i=_.map(e,t);return new E.CompositeUnsubscribe(i).unsubscribe}):E.never()},E.repeatedly=function(t,n){var r=0;return H(new E.Desc(E,"repeatedly",[t,n]),E.fromPoll(t,function(){return n[r++%n.length]}))},E.repeat=function(t){var n=0;return E.fromBinder(function(r){function e(t){return t.isEnd()?u?i():u=!0:o=r(t)}function i(){var i;for(u=!0;u&&o!==E.noMore;)i=t(n++),u=!1,i?s=i.subscribeInternal(e):r(Y());return u=!0}var u=!1,o=E.more,s=function(){};return i(),function(){return s()}})},E.retry=function(t){if(!_.isFunction(t.source))throw new S("'source' option has to be a function");var n=t.source,r=t.retries||0,e=0,i=t.delay||function(){return 0},u=t.isRetryable||function(){return!0},o=!1,s=null;return H(new E.Desc(E,"retry",[t]),E.repeat(function(t){function c(){return n(t).endOnError().withHandler(function(t){return t.isError()?(s=t,u(s.error)&&(0===r||e<r)?void 0:(o=!0,this.push(t))):(t.hasValue()&&(s=null,o=!0),this.push(t))})}if(o)return null;if(s){var a={error:s.error,retriesDone:e},f=E.later(i(a)).filter(!1);return e++,f.concat(E.once().flatMap(c))}return c()}))},E.sequentially=function(t,n){var r=0;return H(new E.Desc(E,"sequentially",[t,n]),E.fromPoll(t,function(){var t=n[r++];return r<n.length?t:r===n.length?[t,Y()]:Y()}))},E.Observable.prototype.skip=function(t){return H(new E.Desc(this,"skip",[t]),this.withHandler(function(n){return n.hasValue()&&t>0?(t--,E.more):this.push(n)}))},E.EventStream.prototype.skipUntil=function(t){var n=t.take(1).map(!0).toProperty(!1);return H(new E.Desc(this,"skipUntil",[t]),this.filter(n))},E.EventStream.prototype.skipWhile=function(t){for(var n=!1,r=arguments.length,e=Array(r>1?r-1:0),i=1;i<r;i++)e[i-1]=arguments[i];return Q(this,t,e,function(t){return H(new E.Desc(this,"skipWhile",[t]),this.withHandler(function(r){return!n&&r.hasValue()&&t(r.value())?E.more:(r.hasValue()&&(n=!0),this.push(r))}))})},E.Observable.prototype.slidingWindow=function(t){var n=arguments.length<=1||void 0===arguments[1]?0:arguments[1];return H(new E.Desc(this,"slidingWindow",[t,n]),this.scan([],function(n,r){return n.concat([r]).slice(-t)}).filter(function(t){return t.length>=n}))};var dt=[],rt=function(t){if(dt.length&&!rt.running)try{rt.running=!0,dt.forEach(function(n){n(t)})}finally{delete rt.running}};E.spy=function(t){return dt.push(t)},E.Property.prototype.startWith=function(t){return H(new E.Desc(this,"startWith",[t]),this.scan(t,function(t,n){return n}))},E.EventStream.prototype.startWith=function(t){return H(new E.Desc(this,"startWith",[t]),E.once(t).concat(this))},E.Observable.prototype.takeWhile=function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return Q(this,t,r,function(t){return H(new E.Desc(this,"takeWhile",[t]),this.withHandler(function(n){return n.filter(t)?this.push(n):(this.push(Y()),E.noMore)}))})},E.Observable.prototype.throttle=function(t){return this.delayChanges(new E.Desc(this,"throttle",[t]),function(n){return n.bufferWithTime(t).map(function(t){return t[t.length-1]})})},f.prototype.firstToPromise=function(t){var n=this;if("function"!=typeof t){if("function"!=typeof Promise)throw new S("There isn't default Promise, use shim or parameter");t=Promise}return new t(function(t,r){return n.subscribe(function(n){return n.hasValue()&&t(n.value()),n.isError()&&r(n.error),E.noMore})})},f.prototype.toPromise=function(t){return this.last().firstToPromise(t)},E.try=function(t){return function(n){try{return E.once(t(n))}catch(t){return new E.Error(t)}}},E.update=function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];for(var i=r.length-1;i>0;)r[i]instanceof Function||(r[i]=_.always(r[i])),r[i]=function(t){return function(){for(var n=arguments.length,r=Array(n),e=0;e<n;e++)r[e]=arguments[e];return function(n){return t.apply(void 0,[n].concat(r))}}}(r[i]),i-=2;return H(new E.Desc(E,"update",[t].concat(r)),E.when.apply(E,r).scan(t,function(t,n){return n(t)}))},E.zipAsArray=function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];var e=ut(n);return H(new E.Desc(E,"zipAsArray",e),E.zipWith(e,function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n}))},E.zipWith=function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];var e=ot(n),i=e[0],u=e[1];return i=_.map(function(t){return t.toEventStream()},i),H(new E.Desc(E,"zipWith",[u].concat(i)),E.when(i,u))},E.Observable.prototype.zip=function(t,n){return H(new E.Desc(this,"zip",[t]),E.zipWith([this,t],n||Array))},g.prototype.subscribe=function(t,n,r){var e="function"==typeof t?{next:t,error:n,complete:r}:t,i={closed:!1,unsubscribe:function(){i.closed=!0,u()}},u=this.observable.subscribe(function(t){t.isError()?(e.error&&e.error(t.error),i.unsubscribe()):t.isEnd()?(i.closed=!0,e.complete&&e.complete()):e.next&&e.next(t.value())});return i},g.prototype[P("observable")]=function(){return this},E.Observable.prototype.toESObservable=function(){return new g(this)},E.Observable.prototype[P("observable")]=E.Observable.prototype.toESObservable,E.fromESObservable=function(t){var n;n=t[P("observable")]?t[P("observable")]():t;var r=new E.Desc(E,"fromESObservable",[n]);return new E.EventStream(r,function(t){var r=n.subscribe({error:function(){t(new E.Error),t(new E.End)},next:function(n){t(new E.Next(n,!0))},complete:function(){t(new E.End)}});return r.unsubscribe?function(){r.unsubscribe()}:r})},"undefined"!=typeof define&&null!==define&&null!=define.amd?(define([],function(){return E}),void 0!==this&&null!==this&&(this.Bacon=E)):"undefined"!=typeof module&&null!==module&&null!=module.exports?(module.exports=E,E.Bacon=E):this.Bacon=E}).call(this);
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.Bacon=n()}(this,function(){"use strict";function t(){}function n(t){return t}function r(t){return t.slice(0)}function e(t){for(var n=arguments.length,r=1;n>1?n>r:r>n;n>1?r++:r--)for(var e in arguments[r])t[e]=arguments[r][e];return t}function i(t,n){function r(){}var e={}.hasOwnProperty;r.prototype=n.prototype,t.prototype=new r;for(var i in n)e.call(n,i)&&(t[i]=n[i]);return t}function u(t){return"undefined"!=typeof Symbol&&Symbol[t]?Symbol[t]:"undefined"!=typeof Symbol&&"function"==typeof Symbol["for"]?Symbol[t]=Symbol["for"](t):"@@"+t}function o(t){this.value=t}function s(){this.id=++Tt}function a(t){return this instanceof a?(s.call(this),void(this.value=t)):new a(t)}function c(t){return this instanceof c?void a.call(this,t):new c(t)}function f(){return this instanceof f?void s.call(this):new f}function h(t){return this instanceof h?(this.error=t,void s.call(this)):new h(t)}function p(t){return new c(t)}function l(t){return new a(t)}function d(){return new f}function v(t){return t&&t._isEvent?t:l(t)}function y(t){if(Ht.length&&!y.running)try{y.running=!0,Ht.forEach(function(n){n(t)})}finally{delete y.running}}function g(t,n,r){this.context=t,this.method=n,this.args=r}function m(t,n){var r=t||n;if(r&&r._isDesc)return t||n;for(var e=arguments.length,i=Array(e>2?e-2:0),u=2;e>u;u++)i[u-2]=arguments[u];return new g(t,n,i)}function b(t,n){return n.desc=t,n}function w(t){return _t(t)?Ot.flatMap(w,t):xt(t)?[t]:("undefined"!=typeof t&&null!==t?t._isSource:void 0)?[t.obs]:[]}function E(t,n){this._subscribe=t,this._handleEvent=n,this.subscribe=Ot.bind(this.subscribe,this),this.handleEvent=Ot.bind(this.handleEvent,this),this.pushing=!1,this.ended=!1,this.prevError=void 0,this.unsubSrc=void 0,this.subscriptions=[],this.queue=[]}function S(t){return function(n){for(var r=arguments.length,e=Array(r>1?r-1:0),i=1;r>i;i++)e[i-1]=arguments[i];if("object"==typeof n&&e.length){var u=n,o=e[0];n=function(){return u[o].apply(u,arguments)},e=e.slice(1)}return t.apply(void 0,[n].concat(e))}}function A(t){return t=Array.prototype.slice.call(t),Nt.apply(void 0,t)}function k(t,n){return function(){for(var r=arguments.length,e=Array(r),i=0;r>i;i++)e[i]=arguments[i];return t.apply(void 0,n.concat(e))}}function _(t){return function(n){return function(r){if("undefined"!=typeof r&&null!==r){var e=r[n];return Ot.isFunction(e)?e.apply(r,t):e}}}}function x(t,n){var r=t.slice(1).split("."),e=Ot.map(_(n),r);return function(t){for(var n,r=0;r<e.length;r++)n=e[r],t=n(t);return t}}function M(t){return"string"==typeof t&&t.length>1&&"."===t.charAt(0)}function I(t,n){return Nt.apply(void 0,[t].concat(n))}function O(t,n,r,e){if(n&&n._isProperty){var i=n.sampledBy(t,function(t,n){return[t,n]});return e.call(i,function(t){var n=t[0];return n}).map(function(t){var n=t[1];return n})}return n=I(n,r),e.call(t,n)}function W(t){if(Ot.isFunction(t))return t;if(M(t)){var n=T(t);return function(t,r){return t[n](r)}}throw new Error("not a function or a field key: "+t)}function T(t){return t.slice(1)}function P(t){this.desc=t,this.id=++qt,this.initialDesc=this.desc}function V(t,n,r){E.call(this,n,r),this.property=t,this.subscribe=Ot.bind(this.subscribe,this),this.current=Mt,this.currentValueRootId=void 0,this.propertyEnded=!1}function H(t,n){return new D(t,N(Mt,n))}function D(t,n,r){P.call(this,t),this.dispatcher=new V(this,n,r),y(this)}function C(t,n,r){var e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Ft;return this instanceof C?(Ot.isFunction(t)&&(r=n,n=t,t=jt),e!==Lt&&(n=B(this,n)),P.call(this,t),this.dispatcher=new E(n,r),void y(this)):new C(t,n,r)}function B(t,n){var r=!1;return function(e){r=!0;try{return n(function(n){return r?void Bt.soonButNotYet(t,function(){e(n)}):e(n)})}finally{r=!1}}}function N(n,r){return function(e){var i=!1,u=!1,s=t,a=Vt,f=function(){return i?void 0:n.forEach(function(n){return i=!0,a=e(new c(n)),a===Pt?(s(),s=t,t):void 0})};return s=r(function(t){return t.hasValue?t.isInitial&&!u?(n=new o(t.value),Vt):(t.isInitial||f(),i=!0,n=new o(t.value),e(t)):(t.isEnd&&(a=f()),a!==Pt?e(t):void 0)}),u=!0,f(),s}}function q(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.unsubscribe=Ot.bind(this.unsubscribe,this),this.unsubscribed=!1,this.subscriptions=[],this.starting=[];for(var n,r=0;r<t.length;r++)n=t[r],this.add(n)}function F(){return new C(m(Qt,"never"),function(n){return n(d()),t})}function L(n){return new D(new g(Qt,"constant",[n]),function(r){return r(p(n)),r(d()),t})}function j(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];return O(this,t,r,function(t){return b(new g(this,"map",[t]),this.withHandler(function(n){return this.push(n.fmap(t))}))})}function Q(t,n){this.obs=t,this.sync=n,this.queue=[]}function U(){Q.apply(this,arguments)}function z(t){Q.call(this,t,!0)}function R(){return Z(C,arguments)}function Y(){return Z(H,arguments)}function $(t){for(var n=t.length,r=[],e=[],i=0,u=[];n>i;){u[i]=t[i],u[i+1]=t[i+1];for(var o,s=Ot.toArray(t[i]),a=G(t[i+1]),c={f:a,ixs:[]},f=!1,h=0;h<s.length;h++){o=s[h];var p=Ot.indexOf(r,o);f||(f=Q.isTrigger(o)),0>p&&(r.push(o),p=r.length-1);for(var l,d=0;d<c.ixs.length;d++)l=c.ixs[d],l.index===p&&l.count++;c.ixs.push({index:p,count:1})}s.length>0&&e.push(c),i+=2}return[r,e,u]}function Z(t,n){if(0===n.length)return F();var r=$(n),e=r[0],i=r[1],u=r[2];if(!e.length)return F();e=Ot.map(Q.fromObservable,e);var o=Ot.any(e,function(t){return t.flatten})&&X(Ot.map(function(t){return t.obs},e)),s=new g(Qt,"when",u),a=t(s,function(t){function n(t){for(var n=0;n<t.ixs.length;n++){var r=t.ixs[n];if(!e[r.index].hasAtLeast(r.count))return!1}return!0}function r(t){for(var n=0;n<t.ixs.length;n++){var r=t.ixs[n];if(!e[r.index].mayHave(r.count))return!0}}function u(t){return!t.source.flatten}function s(s){return function(h){function p(){return Bt.whenDoneWith(a,v)}function l(){if(!(c.length>0))return Vt;for(var r,o=Vt,s=c.pop(),a=0;a<i.length;a++)if(r=i[a],n(r)){for(var f=[],h=0;h<r.ixs.length;h++){var p=e[r.ixs[h].index].consume();f.push(p.value)}var d=r.f.apply(null,f);return o=t(s.e.apply(d)),c.length&&(c=Ot.filter(u,c)),o===Pt?o:l()}}function v(){var n=l();return f&&(Ot.all(e,J)||Ot.all(i,r))&&(n=Pt,t(d())),n===Pt&&h(),n}return s.subscribe(function(n){if(n.isEnd)f=!0,s.markEnded(),p();else if(n.isError)var r=t(n);else s.push(n),s.sync&&(c.push({source:s,e:n}),o||Bt.hasWaiters()?p():v());return r===Pt&&h(),r||Vt})}}var c=[],f=!1;return new q(function(){for(var t,n=[],r=0;r<e.length;r++)t=e[r],n.push(s(t));return n}()).unsubscribe});return a}function X(t){function n(t){if(Ot.contains(r,t))return!0;var e=t.internalDeps();return e.length?(r.push(t),Ot.any(e,n)):(r.push(t),!1)}var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return Ot.any(t,n)}function G(t){return Ot.isFunction(t)?t:Ot.always(t)}function J(t){return!t.sync||t.ended}function K(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return tt(n)}function tt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ft;1===t.length&&_t(t[0])&&(t=t[0]);var r=function(){for(var n=[],r=0;r<t.length;r++)n.push(new z(t[r]));return n}(),e=function(t,r){return new C(t,r,null,n)};return b(new g(Qt,"groupSimultaneous",t),Z(e,[r,function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return n}]))}function nt(t){var n=new g(this,"awaiting",[t]);return b(n,tt([this,t],Lt).map(function(t){return 0===t[1].length}).toProperty(!1).skipDuplicates())}function rt(t){return _t(t[0])?t[0]:Array.prototype.slice.call(t)}function et(t){return Ot.isFunction(t[0])?[rt(Array.prototype.slice.call(t,1)),t[0]]:[rt(Array.prototype.slice.call(t,0,t.length-1)),Ot.last(t)]}function it(n){var r=new C(new g(Qt,"once",[n]),function(e){return Bt.soonButNotYet(r,function(){e(v(n)),e(d())}),t});return r}function ut(t){return 1===t.length&&xt(t[0])?Ot.always(t[0]):A(t)}function ot(t){return xt(t)?t:it(t)}function st(t,n){var r=new C(m(t,"justInitValue"),function(n){var e=void 0,i=t.dispatcher.subscribe(function(t){return t.isEnd||(e=t),Pt});return Bt.whenDoneWith(r,function(){return"undefined"!=typeof e&&null!==e&&n(e),n(d())}),i},null,Lt);return r.concat(n).toProperty()}function at(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ot.id,r=new g(Qt,"fromBinder",[t,n]);return new C(r,function(r){var e=!1,i=!1,u=function(){return e?void 0:"undefined"!=typeof o&&null!==o?(o(),e=!0):i=!0},o=t(function(){for(var t,e=arguments.length,i=Array(e),o=0;e>o;o++)i[o]=arguments[o];var s=n.apply(this,i);_t(s)&&(null!=(t=Ot.last(s))?t._isEvent:void 0)||(s=[s]);for(var a,c=Qt.more,f=0;f<s.length;f++)if(a=s[f],c=r(a=v(a)),c===Qt.noMore||a.isEnd)return u(),c;return c});return i&&u(),u})}function ct(t,n){return b(new g(Qt,"later",[t,n]),at(function(r){var e=function(){return r([n,d()])},i=Qt.scheduler.setTimeout(e,t);return function(){return Qt.scheduler.clearTimeout(i)}}))}function ft(){return this instanceof ft?(this.unsubAll=Ot.bind(this.unsubAll,this),this.subscribeAll=Ot.bind(this.subscribeAll,this),this.guardedSink=Ot.bind(this.guardedSink,this),this.sink=void 0,this.subscriptions=[],this.ended=!1,void C.call(this,new g(Qt,"Bus",[]),this.subscribeAll)):new ft}function ht(t){function n(t){return t[t.length-1]}function r(t,r,e){return n(t)[r]=e,e}function e(t,n){return function(e,i){r(e,t,i[n])}}function i(t,n){return function(e){r(e,t,n)}}function u(t){return _t(t)?[]:{}}function o(t,n){return function(e){var i=u(n);r(e,t,i),e.push(i)}}function s(t){if(xt(t))return!0;if(t&&(t.constructor==Object||t.constructor==Array))for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){var r=t[n];if(s(r))return!0}}function a(t,n){if(xt(n))p.push(n),h.push(e(t,p.length-1));else if(s(n)){var r=function(t){t.pop()};h.push(o(t,n)),f(n),h.push(r)}else h.push(i(t,n))}function c(n){for(var r,e=u(t),i=[e],o=0;o<h.length;o++)(r=h[o])(i,n);return e}function f(t){Ot.each(t,a)}var h=[],p=[],l=s(t)?(f(t),Qt.combineAsArray(p).map(c)):Qt.constant(t);return b(new g(Qt,"combineTemplate",[t]),l)}function pt(n,r){var e,i=this;r=W(r);var u=n,o=!1,s=function(n){var s=!1,a=t,f=Vt,h=function(){s||(s=o=!0,f=n(new c(u)),f===Pt&&(a(),a=t))};return a=i.dispatcher.subscribe(function(t){if(t.hasValue){if(o&&t.isInitial)return Vt;t.isInitial||h(),s=o=!0;var e=u,i=r(e,t.value);return u=i,n(t.apply(i))}return t.isEnd&&(f=h()),f!==Pt?n(t):void 0}),Bt.whenDoneWith(e,h),a};return e=new D(new g(this,"scan",[n,r]),s)}function lt(t){this.observable=t}function dt(t,n,r){var e=Zt(t),i=e[0],u=e[1],o=new g(Qt,"fromEvent",[t,n]);return b(o,at(function(r){return i.call(t,n,r),function(){return u.call(t,n,r)}},r))}function vt(t,n){var r=new g(Qt,"fromPoll",[t,n]);return b(r,at(function(n){var r=Qt.scheduler.setInterval(n,t);return function(){return Qt.scheduler.clearInterval(r)}},n))}function yt(t){return[t,d()]}function gt(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:yt;return b(new g(Qt,"fromPromise",[t]),at(function(r){var e=t.then(r,function(t){return r(new h(t))});return e&&"function"==typeof e.done&&e.done(),n?function(){return"function"==typeof t.abort?t.abort():void 0}:function(){}},r))}function mt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return b(new g(Qt,"interval",[t,n]),vt(t,function(){return l(n)}))}function bt(){var t=rt(arguments);return t.length?new C(new g(Qt,"mergeAll",t),function(n){var r=0,e=function(e){return function(i){return e.dispatcher.subscribe(function(e){if(e.isEnd)return r++,r===t.length?n(d()):Vt;var u=n(e);return u===Pt&&i(),u})}},i=Ot.map(e,t);return new q(i).unsubscribe}):F()}function wt(t,n){var r=0;return b(new g(Qt,"repeatedly",[t,n]),vt(t,function(){return n[r++%n.length]}))}function Et(t){var n=0;return at(function(r){function e(t){return t.isEnd?u?i():u=!0:o=r(t)}function i(){var i;for(u=!0;u&&o!==Pt;)i=t(n++),u=!1,i?s=i.subscribeInternal(e):r(d());return u=!0}var u=!1,o=Vt,s=function(){};return i(),function(){return s()}})}function St(t,n){var r=0;return b(new g(Qt,"sequentially",[t,n]),vt(t,function(){var t=n[r++];return r<n.length?t:r===n.length?[t,d()]:d()}))}function At(t){return function(n){try{return it(t(n))}catch(r){return new h(r)}}}function kt(t){function n(t){return function(){for(var n=arguments.length,r=Array(n),e=0;n>e;e++)r[e]=arguments[e];return function(n){return t.apply(void 0,[n].concat(r))}}}for(var r=arguments.length,e=Array(r>1?r-1:0),i=1;r>i;i++)e[i-1]=arguments[i];for(var u=e.length-1;u>0;)e[u]instanceof Function||(e[u]=Ot.always(e[u])),e[u]=n(e[u]),u-=2;return b(new g(Qt,"update",[t].concat(e)),R.apply(void 0,e).scan(t,function(t,n){return n(t)}))}var _t=Array.isArray||function(t){return t instanceof Array},xt=function(t){return t&&t._isObservable};e(o.prototype,{_isSome:!0,getOrElse:function(){return this.value},get:function(){return this.value},filter:function(t){return t(this.value)?new o(this.value):Mt},map:function(t){return new o(t(this.value))},forEach:function(t){return t(this.value)},isDefined:!0,toArray:function(){return[this.value]},inspect:function(){return"Some("+this.value+")"},toString:function(){return this.inspect()}});var Mt={_isNone:!0,getOrElse:function(t){return t},filter:function(){return Mt},map:function(){return Mt},forEach:function(){},isDefined:!1,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}},It=function(t){return t&&(t._isSome||t.isNone)?t:new o(t)},Ot={indexOf:function(){return Array.prototype.indexOf?function(t,n){return t.indexOf(n)}:function(t,n){for(var r,e=0;e<t.length;e++)if(r=t[e],n===r)return e;return-1}}(),indexWhere:function(t,n){for(var r,e=0;e<t.length;e++)if(r=t[e],n(r))return e;return-1},head:function(t){return t[0]},always:function(t){return function(){return t}},negate:function(t){return function(n){return!t(n)}},empty:function(t){return 0===t.length},tail:function(t){return t.slice(1,t.length)},filter:function(t,n){for(var r,e=[],i=0;i<n.length;i++)r=n[i],t(r)&&e.push(r);return e},map:function(t,n){return function(){for(var r,e=[],i=0;i<n.length;i++)r=n[i],e.push(t(r));return e}()},each:function(t,n){for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var e=t[r];n(r,e)}},toArray:function(t){return _t(t)?t:[t]},contains:function(t,n){return-1!==Ot.indexOf(t,n)},id:function(t){return t},last:function(t){return t[t.length-1]},all:function(t){for(var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ot.id,e=0;e<t.length;e++)if(n=t[e],!r(n))return!1;return!0},any:function(t){for(var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ot.id,e=0;e<t.length;e++)if(n=t[e],r(n))return!0;return!1},without:function(t,n){return Ot.filter(function(n){return n!==t},n)},remove:function(t,n){var r=Ot.indexOf(n,t);return r>=0?n.splice(r,1):void 0},fold:function(t,n,r){for(var e,i=0;i<t.length;i++)e=t[i],n=r(n,e);return n},flatMap:function(t,n){return Ot.fold(n,[],function(n,r){return n.concat(t(r))})},cached:function(t){var n=Mt;return function(){return("undefined"!=typeof n&&null!==n?n._isNone:void 0)&&(n=t(),t=void 0),n}},bind:function(t,n){return function(){return t.apply(n,arguments)}},isFunction:function(t){return"function"==typeof t},toString:function(t){var n,r,e,i={}.hasOwnProperty;try{return Wt++,null==t?"undefined":Ot.isFunction(t)?"function":_t(t)?Wt>5?"[..]":"["+Ot.map(Ot.toString,t).toString()+"]":null!=(null!=t?t.toString:void 0)&&t.toString!==Object.prototype.toString?t.toString():"object"==typeof t?Wt>5?"{..}":(n=function(){var n=[];for(r in t)i.call(t,r)&&(e=function(){try{return t[r]}catch(n){return n}}(),n.push(Ot.toString(r)+":"+Ot.toString(e)));return n}(),"{"+n+"}"):t}finally{Wt--}}},Wt=0,Tt=0;s.prototype._isEvent=!0,s.prototype.isEvent=!0,s.prototype.isEnd=!1,s.prototype.isInitial=!1,s.prototype.isNext=!1,s.prototype.isError=!1,s.prototype.hasValue=!1,s.prototype.filter=function(){return!0},s.prototype.inspect=function(){return this.toString()},s.prototype.log=function(){return this.toString()},s.prototype.toNext=function(){return this},i(a,s),a.prototype.isNext=!0,a.prototype.hasValue=!0,a.prototype.fmap=function(t){return this.apply(t(this.value))},a.prototype.apply=function(t){return new a(t)},a.prototype.filter=function(t){return t(this.value)},a.prototype.toString=function(){return Ot.toString(this.value)},a.prototype.log=function(){return this.value},a.prototype._isNext=!0,i(c,a),c.prototype._isInitial=!0,c.prototype.isInitial=!0,c.prototype.isNext=!1,c.prototype.apply=function(t){return new c(t)},c.prototype.toNext=function(){return new a(this.value)},i(f,s),f.prototype.isEnd=!0,f.prototype.fmap=function(){return this},f.prototype.apply=function(){return this},f.prototype.toString=function(){return"<end>"},i(h,s),h.prototype.isError=!0,h.prototype.fmap=function(){return this},h.prototype.apply=function(){return this},h.prototype.toString=function(){return"<error> "+Ot.toString(this.error)};var Pt="<no-more>",Vt="<more>",Ht=[],Dt=function(t){return Ht.push(t)};e(g.prototype,{_isDesc:!0,deps:function(){return this.cached||(this.cached=w([this.context].concat(this.args))),this.cached},toString:function(){var t=Ot.map(Ot.toString,this.args);return Ot.toString(this.context)+"."+Ot.toString(this.method)+"("+t+")"}});var Ct={setTimeout:function(t,n){return setTimeout(t,n)},setInterval:function(t,n){return setInterval(t,n)},clearInterval:function(t){return clearInterval(t)},clearTimeout:function(t){return clearTimeout(t)},now:function(){return(new Date).getTime()}},Bt=function(){function t(){return Ot.toString({rootEvent:d,processingAfters:w,waiterObs:v,waiters:y,aftersStack:g,aftersStackHeight:m,flushed:b})}function n(t){m>=t||(g[t-1]||(g[t-1]=[[],0]),m=t)}function r(t,n){d?o(t,n):Qt.scheduler.setTimeout(n,0)}function e(t,r){if(!d&&!w)return r();n(1);for(var e=0;m-1>e&&!i(t,g[e][0]);)e++;var o=g[e][0];o.push([t,r]),d||u()}function i(t,n){for(var r=0;r<n.length;r++)if(n[r][0].id==t.id)return!0;return!1}function u(){var t=m;if(t){var r=!w;w=!0;try{for(;m>=t;){var e=g[m-1];if(!e)throw new Error("Unexpected stack top: "+e);var i=e[0],u=e[1];if(!(u<i.length)){e[0]=[],e[1]=0;break}var o=i[u],s=o[1];e[1]++,n(m+1);var a=!1;try{for(s(),a=!0;m>t&&0==g[m-1][0].length;)m--}finally{a||(g=[],m=0)}}}finally{r&&(w=!1)}}}function o(t,n){if(d){var r=y[t.id];return"undefined"==typeof r||null===r?(r=y[t.id]=[n],v.push(t)):r.push(n)}return n()}function s(){for(;v.length>0;)a(0,!0);b={}}function a(t,n){var r=v[t],e=r.id,i=y[e];v.splice(t,1),delete y[e],n&&v.length>0&&c(r);for(var u,o=0;o<i.length;o++)(u=i[o])()}function c(t){if(!b[t.id]){for(var n,r=t.internalDeps(),e=0;e<r.length;e++)if(n=r[e],c(n),y[n.id]){var i=Ot.indexOf(v,n);a(i,!1)}b[t.id]=!0}}function f(t,n,r,e){if(d)return r.apply(n,e);d=t;try{var i=r.apply(n,e);s()}finally{d=void 0,u()}return i}function h(){return d?d.id:void 0}function p(t,n){function r(){return i=!0,o()}var i=!1,u=!1,o=function(){return u=!0};return o=t.dispatcher.subscribe(function(u){return e(t,function(){if(!i){var t=n(u);if(t===Pt)return r()}})}),u&&o(),r}function l(){return v.length>0}var d,v=[],y={},g=[],m=0,b={},w=!1;return{toString:t,whenDoneWith:o,hasWaiters:l,inTransaction:f,currentEventId:h,wrappedSubscribe:p,afterTransaction:e,soonButNotYet:r}}();E.prototype.hasSubscribers=function(){return this.subscriptions.length>0},E.prototype.removeSub=function(t){return this.subscriptions=Ot.without(t,this.subscriptions),this.subscriptions},E.prototype.push=function(t){return t.isEnd&&(this.ended=!0),Bt.inTransaction(t,this,this.pushIt,[t])},E.prototype.pushToSubscriptions=function(t){try{for(var n=this.subscriptions,r=n.length,e=0;r>e;e++){var i=n[e],u=i.sink(t);(u===Pt||t.isEnd)&&this.removeSub(i)}return!0}catch(o){throw this.pushing=!1,this.queue=[],o}},E.prototype.pushIt=function(t){if(this.pushing)return this.queue.push(t),Vt;if(t!==this.prevError){for(t.isError&&(this.prevError=t),this.pushing=!0,this.pushToSubscriptions(t),this.pushing=!1;this.queue.length;)t=this.queue.shift(),this.push(t);return this.hasSubscribers()?Vt:(this.unsubscribeFromSource(),Pt)}},E.prototype.handleEvent=function(t){return this._handleEvent?this._handleEvent(t):this.push(t)},E.prototype.unsubscribeFromSource=function(){this.unsubSrc&&this.unsubSrc(),this.unsubSrc=void 0},E.prototype.subscribe=function(n){var r;return this.ended?(n(d()),t):(r={sink:n},this.subscriptions.push(r),1===this.subscriptions.length&&(this.unsubSrc=this._subscribe(this.handleEvent)),function(t){return function(){return t.removeSub(r),t.hasSubscribers()?void 0:t.unsubscribeFromSource()}}(this))};var Nt=S(function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];return Ot.isFunction(t)?r.length?k(t,r):t:M(t)?x(t,r):Ot.always(t)}),qt=0;e(P.prototype,{_isObservable:!0,subscribe:function(t){return Bt.wrappedSubscribe(this,t)},subscribeInternal:function(t){return this.dispatcher.subscribe(t)},onValue:function(){var t=A(arguments);return this.subscribe(function(n){return n.hasValue?t(n.value):void 0})},onValues:function(t){return this.onValue(function(n){return t.apply(void 0,n)})},onError:function(){var t=A(arguments);return this.subscribe(function(n){return n.isError?t(n.error):void 0})},onEnd:function(){var t=A(arguments);return this.subscribe(function(n){return n.isEnd?t():void 0})},name:function(t){return this._name=t,this},withDescription:function(){return this.desc=m.apply(void 0,arguments),this},toString:function(){return this._name?this._name:this.desc.toString()},deps:function(){return this.desc.deps()},internalDeps:function(){return this.initialDesc.deps()}}),P.prototype.assign=P.prototype.onValue,P.prototype.forEach=P.prototype.onValue,P.prototype.inspect=P.prototype.toString,i(V,E),e(V.prototype,{push:function(t){return t.isEnd&&(this.propertyEnded=!0),t.hasValue&&(this.current=new o(t),this.currentValueRootId=Bt.currentEventId()),E.prototype.push.call(this,t)},maybeSubSource:function(n,r){return r===Qt.noMore?t:this.propertyEnded?(n(d()),t):E.prototype.subscribe.call(this,n)},subscribe:function(t){var n=this,r=Qt.more;if(this.current.isDefined&&(this.hasSubscribers()||this.propertyEnded)){var e=Bt.currentEventId(),i=this.currentValueRootId;return!this.propertyEnded&&i&&e&&e!==i?(Bt.whenDoneWith(this.property,function(){return n.currentValueRootId===i?t(p(n.current.get().value)):void 0}),this.maybeSubSource(t,r)):(Bt.inTransaction(void 0,this,function(){return r=t(p(this.current.get().value))},[]),this.maybeSubSource(t,r))}return this.maybeSubSource(t,r)}}),i(D,P),e(D.prototype,{_isProperty:!0,changes:function(){var t=this;return new C(new g(this,"changes",[]),function(n){return t.dispatcher.subscribe(function(t){return t.isInitial?void 0:n(t)})})},withHandler:function(t){return new D(new g(this,"withHandler",[t]),this.dispatcher.subscribe,t)},toProperty:function(){return this},toEventStream:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ft;return new C(new g(this,"toEventStream",[]),function(n){return t.dispatcher.subscribe(function(t){return n(t.toNext())})},null,n)}});var Ft={forceAsync:!0},Lt={forceAsync:!1},jt=m("Bacon","new EventStream",[]);i(C,P),e(C.prototype,{_isEventStream:!0,toProperty:function(t){var n=0===arguments.length?Mt:It(t),r=this.dispatcher,e=new g(this,"toProperty",[t]),i=function(t){return r.subscribe(t)};return new D(e,N(n,i))},toEventStream:function(){return this},withHandler:function(t){return new C(new g(this,"withHandler",[t]),this.dispatcher.subscribe,t)}}),e(q.prototype,{add:function(n){var r=this;if(!this.unsubscribed){var e=!1,i=t;this.starting.push(n);var u=function(){return r.unsubscribed?void 0:(e=!0,r.remove(i),Ot.remove(n,r.starting))};return i=n(this.unsubscribe,u),this.unsubscribed||e?i():this.subscriptions.push(i),Ot.remove(n,this.starting),i}},remove:function(t){return this.unsubscribed?void 0:void 0!==Ot.remove(t,this.subscriptions)?t():void 0},unsubscribe:function(){if(!this.unsubscribed){this.unsubscribed=!0;for(var t=this.subscriptions,n=0;n<t.length;n++)t[n]();return this.subscriptions=[],this.starting=[],[]}},count:function(){return this.unsubscribed?0:this.subscriptions.length+this.starting.length},empty:function(){return 0===this.count()}});var Qt={toString:function(){return"Bacon"},_:Ot,Event:s,Next:a,Initial:c,Error:h,End:f,noMore:Pt,more:Vt,Desc:g,spy:Dt,UpdateBarrier:Bt,scheduler:Ct,Dispatcher:E,Observable:P,EventStream:C,Property:D,CompositeUnsubscribe:q,never:F,constant:L,version:"<version>"};Qt.Bacon=Qt,P.prototype.map=j,P.prototype.withStateMachine=function(t,n){var r=t,e=new g(this,"withStateMachine",[t,n]);return b(e,this.withHandler(function(t){var e=n(r,t),i=e[0],u=e[1];r=i;for(var o,s=Vt,a=0;a<u.length;a++)if(o=u[a],s=this.push(o),s===Pt)return s;return s}))};var Ut=function(t,n){return t===n},zt=function(t){return"undefined"!=typeof t&&null!==t?t._isNone:!1};P.prototype.skipDuplicates=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ut,n=new g(this,"skipDuplicates",[]);return b(n,this.withStateMachine(Mt,function(n,r){return r.hasValue?r.isInitial||zt(n)||!t(n.get(),r.value)?[new o(r.value),[r]]:[n,[]]:[n,[r]]}))},e(Q.prototype,{_isSource:!0,subscribe:function(t){return this.obs.dispatcher.subscribe(t)},toString:function(){return this.obs.toString()},markEnded:function(){return this.ended=!0,!0},consume:function(){return this.queue[0]},push:function(t){this.queue=[t]},mayHave:function(){return!0},hasAtLeast:function(){return this.queue.length},flatten:!0}),i(U,Q),e(U.prototype,{consume:function(){return this.queue.shift()},push:function(t){return this.queue.push(t)},mayHave:function(t){return!this.ended||this.queue.length>=t},hasAtLeast:function(t){return this.queue.length>=t},flatten:!1}),i(z,Q),e(z.prototype,{consume:function(){var t=this.queue;return this.queue=[],{value:t}},push:function(t){return this.queue.push(t.value)},hasAtLeast:function(){return!0}}),Q.isTrigger=function(t){return null==t?!1:t._isSource?t.sync:t._isEventStream},Q.fromObservable=function(t){return null!=t&&t._isSource?t:null!=t&&t._isProperty?new Q(t,!1):new U(t,!0)},Qt.when=R,Qt.groupSimultaneous=K,P.prototype.awaiting=nt,Qt.combineAsArray=function(){var t=rt(arguments);if(t.length){for(var n=[],r=0;r<t.length;r++){var e=xt(t[r])?t[r]:Qt.constant(t[r]);n.push(new Q(e,!0))}return b(new Qt.Desc(Qt,"combineAsArray",t),Y(n,function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return n}))}return L([])},Qt.onValues=function(){return Qt.combineAsArray(Array.prototype.slice.call(arguments,0,arguments.length-1)).onValues(arguments[arguments.length-1])},Qt.combineWith=function(){var t=et(arguments),n=t[0],r=t[1],e=new g(Qt,"combineWith",[r].concat(n));return b(e,Qt.combineAsArray(n).map(function(t){return r.apply(void 0,t)}))},P.prototype.combine=function(t,n){var r=W(n),e=new g(this,"combine",[t,n]);return b(e,Qt.combineAsArray(this,t).map(function(t){return r(t[0],t[1])}))},P.prototype.not=function(){return b(new g(this,"not",[]),this.map(function(t){return!t}))},D.prototype.and=function(t){return b(new g(this,"and",[t]),this.combine(t,function(t,n){return t&&n}))},D.prototype.or=function(t){return b(new g(this,"or",[t]),this.combine(t,function(t,n){return t||n}))},C.prototype.bufferWithTime=function(t){return b(new g(this,"bufferWithTime",[t]),this.bufferWithTimeOrCount(t,Number.MAX_VALUE))},C.prototype.bufferWithCount=function(t){return b(new g(this,"bufferWithCount",[t]),this.bufferWithTimeOrCount(void 0,t))},C.prototype.bufferWithTimeOrCount=function(t,n){var r=function(r){return r.values.length===n?r.flush():void 0!==t?r.schedule():void 0},e=new g(this,"bufferWithTimeOrCount",[t,n]);return b(e,this.buffer(t,r,r))},C.prototype.buffer=function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i={scheduled:null,end:void 0,values:[],flush:function(){if(this.scheduled&&(Qt.scheduler.clearTimeout(this.scheduled),this.scheduled=null),this.values.length>0){var t=this.values;this.values=[];var n=this.push(l(t));if(null!=this.end)return this.push(this.end);if(n!==Pt)return e(this)}else if(null!=this.end)return this.push(this.end)},schedule:function(){var t=this;return this.scheduled?void 0:this.scheduled=n(function(){return t.flush()})}},u=Vt;if(!Ot.isFunction(n)){var o=n;n=function(t){return Qt.scheduler.setTimeout(t,o)}}return b(new g(this,"buffer",[]),this.withHandler(function(t){var n=this;return i.push=function(t){return n.push(t)},t.isError?u=this.push(t):t.isEnd?(i.end=t,i.scheduled||i.flush()):(i.values.push(t.value),r(i)),u}))},P.prototype.filter=function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];return O(this,t,r,function(t){return b(new g(this,"filter",[t]),this.withHandler(function(n){return n.filter(t)?this.push(n):Vt}))})},Qt.once=it,P.prototype.flatMap_=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this,e=[r],i=[],u=this._isProperty,o=u?H:C,s=!1,a=o(n.desc||new g(this,"flatMap_",arguments),function(e){var o=new q,a=[],c=function(n){if(u&&n.isInitial){if(s)return Vt;s=!0}var r=ot(t(n));return i.push(r),o.add(function(t,n){return r.dispatcher.subscribe(function(u){if(u.isEnd)return Ot.remove(r,i),f(),h(n),Pt;u=u.toNext();var o=e(u);return o===Pt&&t(),o})})},f=function(){var t=a.shift();return t?c(t):void 0},h=function(t){return t(),o.empty()?e(d()):void 0};return o.add(function(t,i){return r.dispatcher.subscribe(function(t){return t.isEnd?h(i):t.isError&&!n.mapError?e(t):n.firstOnly&&o.count()>1?Vt:o.unsubscribed?Pt:n.limit&&o.count()>n.limit?a.push(t):c(t)})}),o.unsubscribe});return a.internalDeps=function(){return i.length?e.concat(i):e},a};var Rt=function(t){return function(n){return t(n.value)}};P.prototype.flatMapWithConcurrencyLimit=function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];return this.flatMap_(Rt(ut(r)),{limit:t,desc:new g(this,"flatMapWithConcurrencyLimit",[t].concat(r))})},P.prototype.flatMapConcat=function(){var t=new g(this,"flatMapConcat",Array.prototype.slice.call(arguments,0));return b(t,this.flatMapWithConcurrencyLimit.apply(this,[1].concat(Array.prototype.slice.call(arguments))))},C.prototype.concat=function(n){var r=this;return new C(new g(r,"concat",[n]),function(e){var i=t,u=r.dispatcher.subscribe(function(t){return t.isEnd?i=n.toEventStream().dispatcher.subscribe(e):e(t)});return function(){return u(),i()}})},D.prototype.concat=function(t){return st(this,this.changes().concat(t))},Qt.concatAll=function(){var t=rt(arguments);return t.length?b(new g(Qt,"concatAll",t),Ot.fold(Ot.tail(t),Ot.head(t).toEventStream(),function(t,n){return t.concat(n)})):F()},Qt.fromBinder=at,Qt.later=ct,P.prototype.bufferingThrottle=function(t){var n=new g(this,"bufferingThrottle",[t]);return b(n,this.flatMapConcat(function(n){return it(n).concat(ct(t).filter(!1))}))},D.prototype.bufferingThrottle=function(){return P.prototype.bufferingThrottle.apply(this,arguments).toProperty()},i(ft,C),e(ft.prototype,{unsubAll:function(){for(var t,n=this.subscriptions,r=0;r<n.length;r++)t=n[r],"function"==typeof t.unsub&&t.unsub()},subscribeAll:function(t){if(this.ended)t(d());else{this.sink=t;for(var n,e=r(this.subscriptions),i=0;i<e.length;i++)n=e[i],this.subscribeInput(n)}return this.unsubAll},guardedSink:function(t){var n=this;return function(r){return r.isEnd?(n.unsubscribeInput(t),Qt.noMore):n.sink(r)}},subscribeInput:function(t){return t.unsub=t.input.dispatcher.subscribe(this.guardedSink(t.input)),t.unsub},unsubscribeInput:function(t){for(var n,r=this.subscriptions,e=0;e<r.length;e++)if(n=r[e],n.input===t)return"function"==typeof n.unsub&&n.unsub(),void this.subscriptions.splice(e,1)},plug:function(t){var n=this;if(!this.ended){var r={input:t};return this.subscriptions.push(r),"undefined"!=typeof this.sink&&this.subscribeInput(r),function(){return n.unsubscribeInput(t)}}},end:function(){return this.ended=!0,this.unsubAll(),"function"==typeof this.sink?this.sink(d()):void 0;
},push:function(t){if(!this.ended&&"function"==typeof this.sink){var n=!this.pushing;if(!n)return this.pushQueue||(this.pushQueue=[]),void this.pushQueue.push(t);this.pushing=!0;try{return this.sink(l(t))}finally{if(n&&this.pushQueue){for(var r=0;r<this.pushQueue.length;){var e=this.pushQueue[r];this.sink(l(e)),r++}this.pushQueue=null}this.pushing=!1}}},error:function(t){return"function"==typeof this.sink?this.sink(new h(t)):void 0}}),Qt.Bus=ft,P.prototype.flatMap=function(){return this.flatMap_(Rt(ut(arguments)),{desc:new g(this,"flatMap",arguments)})};var Yt=function(t,n){return S(function(r){for(var e=k(n,[function(t,n){return r.apply(void 0,t.concat([n]))}]),i=arguments.length,u=Array(i>1?i-1:0),o=1;i>o;o++)u[o-1]=arguments[o];return b(new g(Qt,t,[r].concat(u)),Qt.combineAsArray(u).flatMap(e).changes())})};Qt.fromCallback=Yt("fromCallback",function(n){for(var r=arguments.length,e=Array(r>1?r-1:0),i=1;r>i;i++)e[i-1]=arguments[i];return at(function(r){return I(n,e)(r),t},function(t){return[t,d()]})}),Qt.fromNodeCallback=Yt("fromNodeCallback",function(n){for(var r=arguments.length,e=Array(r>1?r-1:0),i=1;r>i;i++)e[i-1]=arguments[i];return at(function(r){return I(n,e)(r),t},function(t,n){return t?[new h(t),d()]:[n,d()]})}),Qt.combineTemplate=ht,P.prototype.mapEnd=function(){var t=A(arguments);return b(new g(this,"mapEnd",[t]),this.withHandler(function(n){return n.isEnd?(this.push(l(t(n))),this.push(d()),Pt):this.push(n)}))},P.prototype.skipErrors=function(){return b(new g(this,"skipErrors",[]),this.withHandler(function(t){return t.isError?Vt:this.push(t)}))},P.prototype.takeUntil=function(t){var n={},r=tt([this.mapEnd(n),t.skipErrors()],Lt);this instanceof D&&(r=r.toProperty());var e=r.withHandler(function(t){if(t.hasValue){var r=t.value,e=r[0],i=r[1];if(i.length)return this.push(d());for(var u,o=Vt,s=0;s<e.length;s++)u=e[s],o=u===n?this.push(d()):this.push(l(u));return o}return this.push(t)});return b(new g(this,"takeUntil",[t]),e)},P.prototype.flatMapLatest=function(){var t=ut(arguments),n=this._isProperty?this.toEventStream(Lt):this,r=n.flatMap(function(r){return ot(t(r)).takeUntil(n)});return this._isProperty&&(r=r.toProperty()),b(new g(this,"flatMapLatest",[t]),r)},D.prototype.delayChanges=function(t,n){return b(t,st(this,n(this.changes())))},C.prototype.delayChanges=function(t,n){return b(t,n(this))},P.prototype.delay=function(t){return this.delayChanges(new g(this,"delay",[t]),function(n){return n.flatMap(function(n){return ct(t,n)})})},Qt.Observable.prototype.debounce=function(t){return this.delayChanges(new g(this,"debounce",[t]),function(n){return n.flatMapLatest(function(n){return Qt.later(t,n)})})},Qt.Observable.prototype.debounceImmediate=function(t){return this.delayChanges(new g(this,"debounceImmediate",[t]),function(n){return n.flatMapFirst(function(n){return Qt.once(n).concat(Qt.later(t).filter(!1))})})},P.prototype.decode=function(t){return b(new g(this,"decode",[t]),this.combine(ht(t),function(t,n){return n[t]}))},P.prototype.scan=pt,P.prototype.diff=function(t,n){return n=W(n),b(new g(this,"diff",[t,n]),this.scan([t],function(t,r){return[r,n(t[0],r)]}).filter(function(t){return 2===t.length}).map(function(t){return t[1]}))},P.prototype.doAction=function(){var t=A(arguments);return b(new g(this,"doAction",[t]),this.withHandler(function(n){return n.hasValue&&t(n.value),this.push(n)}))},P.prototype.doEnd=function(){var t=A(arguments);return b(new g(this,"doEnd",[t]),this.withHandler(function(n){return n.isEnd&&t(),this.push(n)}))},P.prototype.doError=function(){var t=A(arguments);return b(new g(this,"doError",[t]),this.withHandler(function(n){return n.isError&&t(n.error),this.push(n)}))},P.prototype.doLog=function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return b(new g(this,"doLog",n),this.withHandler(function(t){if("undefined"!=typeof console&&null!==console&&"function"==typeof console.log){var r;(r=console).log.apply(r,n.concat([t.log()]))}return this.push(t)}))},P.prototype.endOnError=function(t){("undefined"==typeof t||null===t)&&(t=!0);for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];return O(this,t,r,function(t){return b(new g(this,"endOnError",[]),this.withHandler(function(n){return n.isError&&t(n.error)?(this.push(n),this.push(d())):this.push(n)}))})},P.prototype.errors=function(){return b(new g(this,"errors",[]),this.filter(function(){return!1}))},lt.prototype.subscribe=function(t,n,r){var e="function"==typeof t?{next:t,error:n,complete:r}:t,i={closed:!1,unsubscribe:function(){i.closed=!0,u()}},u=this.observable.subscribe(function(t){t.isError?(e.error&&e.error(t.error),i.unsubscribe()):t.isEnd?(i.closed=!0,e.complete&&e.complete()):e.next&&e.next(t.value)});return i},lt.prototype[u("observable")]=function(){return this},P.prototype.toESObservable=function(){return new lt(this)},P.prototype[u("observable")]=P.prototype.toESObservable,P.prototype.take=function(t){return 0>=t?F():b(new g(this,"take",[t]),this.withHandler(function(n){return n.hasValue?(t--,t>0?this.push(n):(0===t&&this.push(n),this.push(d()),Pt)):this.push(n)}))},P.prototype.first=function(){return b(new g(this,"first",[]),this.take(1))},P.prototype.flatMapEvent=function(){return this.flatMap_(ut(arguments),{mapError:!0,desc:new g(this,"flatMapEvent",arguments)})},P.prototype.flatMapFirst=function(){return this.flatMap_(Rt(ut(arguments)),{firstOnly:!0,desc:new g(this,"flatMapFirst",arguments)})},P.prototype.mapError=function(){var t=A(arguments);return b(new g(this,"mapError",[t]),this.withHandler(function(n){return n.isError?this.push(l(t(n.error))):this.push(n)}))},P.prototype.flatMapError=function(t){return this.flatMap_(function(n){return n instanceof h?t(n.error):n},{mapError:!0,desc:new g(this,"flatMapError",[t])})},P.prototype.flatScan=function(t,n){var r=t;return this.flatMapConcat(function(t){return ot(n(r,t)).doAction(function(t){return r=t})}).toProperty(t)},C.prototype.sampledBy=function(t,n){return b(new g(this,"sampledBy",[t,n]),this.toProperty().sampledBy(t,n))},D.prototype.sampledBy=function(t,n){n="undefined"!=typeof n&&null!==n?W(n):Qt._.id;var r=new Q(this,!1),e=new Q(t,!0),i=t._isProperty?Y:R,u=i([r,e],n);return b(new g(this,"sampledBy",[t,n]),u)},D.prototype.sample=function(t){return b(new g(this,"sample",[t]),this.sampledBy(Qt.interval(t,{})))},P.prototype.map=function(t){return t&&t._isProperty?t.sampledBy(this,n):j.apply(this,arguments)},P.prototype.fold=function(t,n){return b(new g(this,"fold",[t,n]),this.scan(t,n).sampledBy(this.filter(!1).mapEnd().toProperty()))},P.prototype.reduce=P.prototype.fold,Qt.fromArray=function(t){if(t.length){var n=0,r=new C(new g(Qt,"fromArray",[t]),function(e){function i(){if(a=!0,!s){for(s=!0;a;)if(a=!1,o!==Pt&&!u){var c=t[n++];o=e(v(c)),o!==Pt&&(n===t.length?e(d()):Bt.afterTransaction(r,i))}return s=!1}}var u=!1,o=Vt,s=!1,a=!1;return Bt.soonButNotYet(r,i),function(){return u=!0}});return r}return b(new g(Qt,"fromArray",t),F())},Qt.fromESObservable=function(t){var n;n=t[u("observable")]?t[u("observable")]():t;var r=new g(Qt,"fromESObservable",[n]);return new C(r,function(t){var r=n.subscribe({error:function(){t(new Qt.Error),t(new Qt.End)},next:function(n){t(new Qt.Next(n,!0))},complete:function(){t(new Qt.End)}});return r.unsubscribe?function(){r.unsubscribe()}:r})};var $t=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"],["bind","unbind"]],Zt=function(t){for(var n,r=0;r<$t.length;r++){n=$t[r];var e=[t[n[0]],t[n[1]]];if(e[0]&&e[1])return e}for(var i=0;i<$t.length;i++){n=$t[i];var u=t[n[0]];if(u)return[u,function(){}]}throw new Error("No suitable event methods in "+t)};return Qt.fromEvent=Qt.fromEventTarget=dt,Qt.fromPoll=vt,Qt.fromPromise=gt,P.prototype.groupBy=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ot.id,r={},e=this;return e.filter(function(n){return!r[t(n)]}).map(function(i){var u=t(i),o=e.filter(function(n){return t(n)===u}),s=it(i).concat(o),a=n(s,i).withHandler(function(t){return this.push(t),t.isEnd?delete r[u]:void 0});return r[u]=a,a})},C.prototype.holdWhen=function(t){var n=!1,r=[],e=this,i=!1;return new C(new g(this,"holdWhen",[t]),function(u){var o=new q,s=!1,a=function(t){return"function"==typeof t&&t(),o.empty()&&s?u(d()):void 0};return o.add(function(e,o){return t.subscribeInternal(function(t){if(!t.hasValue)return t.isEnd?a(o):u(t);if(n=t.value,!n){var e=r;return r=[],function(){for(var t,n=[],r=0;r<e.length;r++)t=e[r],n.push(u(l(t)));return i&&(n.push(u(d())),o()),n}()}})}),o.add(function(t,o){return e.subscribeInternal(function(t){return n&&t.hasValue?r.push(t.value):t.isEnd&&r.length?(i=!0,a(o)):u(t)})}),s=!0,a(),o.unsubscribe})},Qt.interval=mt,Qt.$={},Qt.$.asEventStream=function(t,n,r){var e=this;return Ot.isFunction(n)&&(r=n,n=void 0),b(new g(this.selector||this,"asEventStream",[t]),at(function(r){return e.on(t,n,r),function(){return e.off(t,n,r)}},r))},"undefined"!=typeof jQuery&&jQuery&&(jQuery.fn.asEventStream=Qt.$.asEventStream),"undefined"!=typeof Zepto&&Zepto&&(Zepto.fn.asEventStream=Qt.$.asEventStream),P.prototype.last=function(){var t;return b(new g(this,"last",[]),this.withHandler(function(n){return n.isEnd?(t&&this.push(t),this.push(d()),Pt):void(t=n)}))},P.prototype.log=function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return this.subscribe(function(t){if("undefined"!=typeof console&&"function"==typeof console.log){var r;(r=console).log.apply(r,n.concat([t.log()]))}}),this},C.prototype.merge=function(t){var n=this;return b(new g(n,"merge",[t]),bt(this,t))},Qt.mergeAll=bt,Qt.repeatedly=wt,Qt.repeat=Et,Qt.retry=function(t){if(!Ot.isFunction(t.source))throw new Error("'source' option has to be a function");var n=t.source,r=t.retries||0,e=0,i=t.delay||function(){return 0},u=t.isRetryable||function(){return!0},o=!1,s=null;return b(new g(Qt,"retry",[t]),Qt.repeat(function(t){function a(){return n(t).endOnError().withHandler(function(t){return t.isError?(s=t,u(s.error)&&(0===r||r>e)?void 0:(o=!0,this.push(t))):(t.hasValue&&(s=null,o=!0),this.push(t))})}if(o)return null;if(s){var c={error:s.error,retriesDone:e},f=ct(i(c)).filter(!1);return e++,f.concat(Qt.once().flatMap(a))}return a()}))},Qt.sequentially=St,P.prototype.skip=function(t){return b(new g(this,"skip",[t]),this.withHandler(function(n){return n.hasValue&&t>0?(t--,Vt):this.push(n)}))},C.prototype.skipUntil=function(t){var n=t.take(1).map(!0).toProperty(!1);return b(new g(this,"skipUntil",[t]),this.filter(n))},C.prototype.skipWhile=function(t){for(var n=!1,r=arguments.length,e=Array(r>1?r-1:0),i=1;r>i;i++)e[i-1]=arguments[i];return O(this,t,e,function(t){return b(new g(this,"skipWhile",[t]),this.withHandler(function(r){return!n&&r.hasValue&&t(r.value)?Vt:(r.hasValue&&(n=!0),this.push(r))}))})},D.prototype.startWith=function(t){return b(new g(this,"startWith",[t]),this.scan(t,function(t,n){return n}))},C.prototype.startWith=function(t){return b(new g(this,"startWith",[t]),it(t).concat(this))},P.prototype.slidingWindow=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return b(new g(this,"slidingWindow",[t,n]),this.scan([],function(n,r){return n.concat([r]).slice(-t)}).filter(function(t){return t.length>=n}))},P.prototype.takeWhile=function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;n>e;e++)r[e-1]=arguments[e];return O(this,t,r,function(t){return b(new g(this,"takeWhile",[t]),this.withHandler(function(n){return n.filter(t)?this.push(n):(this.push(d()),Pt)}))})},P.prototype.throttle=function(t){return this.delayChanges(new g(this,"throttle",[t]),function(n){return n.bufferWithTime(t).map(function(t){return t[t.length-1]})})},P.prototype.firstToPromise=function(t){var n=this;if("function"!=typeof t){if("function"!=typeof Promise)throw new Error("There isn't default Promise, use shim or parameter");t=Promise}return new t(function(t,r){return n.subscribe(function(n){return n.hasValue&&t(n.value),n.isError&&r(n.error),Pt})})},P.prototype.toPromise=function(t){return this.last().firstToPromise(t)},Qt["try"]=At,Qt.update=kt,Qt.zipAsArray=function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];var e=rt(n);return b(new g(Qt,"zipAsArray",e),Qt.zipWith(e,function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return n}))},Qt.zipWith=function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];var e=et(n),i=e[0],u=e[1];return i=Ot.map(function(t){return t.toEventStream()},i),b(new g(Qt,"zipWith",[u].concat(i)),Qt.when(i,u))},P.prototype.zip=function(t,n){return b(new g(this,"zip",[t]),Qt.zipWith([this,t],n||Array))},Qt});
{
"name": "baconjs",
"description": "A small functional reactive programming lib for JavaScript.",
"version": "1.0.1",
"version": "2.0.0",
"keywords": [

@@ -34,4 +34,21 @@ "bacon.js",

"devDependencies": {
"babel": "^5.8.23",
"rxjs": "^5.2.0",
"babel-cli": "^6.3.17",
"babel-core": "^6.3.26",
"babel-plugin-check-es2015-constants": "^6.3.13",
"babel-plugin-transform-es2015-arrow-functions": "^6.3.13",
"babel-plugin-transform-es2015-block-scoping": "^6.3.13",
"babel-plugin-transform-es2015-classes": "^6.3.15",
"babel-plugin-transform-es2015-constants": "^6.1.4",
"babel-plugin-transform-es2015-destructuring": "^6.3.15",
"babel-plugin-transform-es2015-modules-commonjs": "^6.3.16",
"babel-plugin-transform-es2015-parameters": "^6.3.26",
"babel-plugin-transform-es2015-shorthand-properties": "^6.3.13",
"babel-plugin-transform-es2015-spread": "^6.3.14",
"babel-plugin-transform-es3-member-expression-literals": "^6.3.13",
"babel-plugin-transform-es3-property-literals": "^6.3.13",
"babel-plugin-transform-object-rest-spread": "^6.3.13",
"babel-register": "^6.3.13",
"babel-runtime": "^6.3.19",
"babelify": "^7.2.0",
"benchmark": "1.0.0",

@@ -45,16 +62,10 @@ "bluebird": "^2",

"coffeeify": "^1.0.0",
"coffeelint": "^1.9.2",
"es6-promise": "^3.0.2",
"escodegen": "^1.6.1",
"eslint": "^1.10.3",
"eslint-config-defaults": "^7.1.1",
"esprima": "^2.0.0",
"estraverse": "^1.9.1",
"estraverse": "^4.1.1",
"git-rev": "^0.2.1",
"github": "^0.2.4",
"grunt": "0.4",
"grunt-cli": "0.1.13",
"grunt-coffeelint": "0.0.16",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-eslint": "^17.2.0",
"grunt-shell": "^1.1.2",
"jasmine-node": "^1.14.5",

@@ -65,2 +76,6 @@ "jquery": "^2.1.4",

"mocha": "^2.1.0",
"recast": "^0.11.0",
"require-globify": "^1.3.0",
"rollup": "^0.55",
"rollup-plugin-babel": "^2.3.3",
"shelljs": "^0.5.3",

@@ -78,6 +93,14 @@ "sinon": "^1.12.2",

"scripts": {
"test": "./runtests",
"pre-publish": "grunt"
"test": "./scripts/runtests",
"perftest": "performance/PerformanceTest.coffee",
"lint": "eslint src",
"dist": "./scripts/dist",
"readme": "coffee readme/readme.coffee",
"prepublish": "npm run lint && npm run dist && npm run readme",
"version": "scripts/version",
"browsertest-bundle": "browsertest/browserify",
"browsertest-open": "open browsertest/mocha.runner.html",
"browserstack": "browsertest/browserstack"
},
"main": "dist/Bacon.js"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc