Socket
Socket
Sign inDemoInstall

kefir

Package Overview
Dependencies
0
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.2 to 2.1.0

README.md

9

changelog.md

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

## 2.1.0 (28/04/2015)
- New method `.last`
- The `.reduce` method is deprecated in favor of `.scan(...).last()`
## 2.0.2 (26/04/2015)
A technical release (to be latest after `1.3.2`, so `npm install kefir` would instal 2.0.2 by default)
## 2.0.1 (26/04/2015)

@@ -2,0 +11,0 @@

@@ -432,1 +432,30 @@ # Deprecated API Methods documentation

```
### obs.reduce(fn, [seed])
Similar to [.scan](http://pozadi.github.io/kefir/#scan),
but emits only the last result just before end.
```js
// Example
var source = Kefir.sequentially(100, [1, 2, 2, 3]);
var result = source.reduce(function(prev, next) {
return next + prev;
}, 0);
result.log();
// Output
> [sequentially.reduce] <value> 8
> [sequentially.reduce] <end>
// Events diagram
source: ---1---2---2---3 X
result: ----------------8X
```

33

dist/kefir.js

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

/*! Kefir.js v2.0.2
/*! Kefir.js v2.1.0
* https://github.com/pozadi/kefir

@@ -1899,6 +1899,26 @@ */

// .last()
withOneSource('last', {
_init: function() {
this._lastValue = NOTHING;
},
_free: function() {
this._lastValue = null;
},
_handleValue: function(x) {
this._lastValue = x;
},
_handleEnd: function(__, isCurrent) {
if (this._lastValue !== NOTHING) {
this._send(VALUE, this._lastValue, isCurrent);
}
this._send(END, null, isCurrent);
}
});
// .map(fn)

@@ -2209,5 +2229,16 @@

Stream.prototype.reduce = deprecated(
'.reduce(fn, seed)',
'.scan(fn, seed).last()',
Stream.prototype.reduce
);
Property.prototype.reduce = deprecated(
'.reduce(fn, seed)',
'.scan(fn, seed).last()',
Property.prototype.reduce
);
// .beforeEnd(fn)

@@ -2214,0 +2245,0 @@

6

dist/kefir.min.js

@@ -1,7 +0,7 @@

/*! Kefir.js v2.0.2
/*! Kefir.js v2.1.0
* https://github.com/pozadi/kefir
*/
!function(a){"use strict";function b(){for(var a=0;a<arguments.length;a++)if(!arguments[a])return arguments[a];return arguments[a-1]}function c(){for(var a=0;a<arguments.length;a++)if(arguments[a])return arguments[a];return arguments[a-1]}function d(a){return!a}function e(a,b){var c,d,e,f;if(0===a.length)return b;if(0===b.length)return a;for(f=0,c=new Array(a.length+b.length),d=a.length,e=0;d>e;e++,f++)c[f]=a[e];for(d=b.length,e=0;d>e;e++,f++)c[f]=b[e];return c}function f(a,b){var c,d=a.length,e=new Array(d);for(c=0;d>c;c++)e[(c+b)%d]=a[c];return e}function g(a,b){var c,d=a.length;for(c=0;d>c;c++)if(a[c]===b)return c;return-1}function h(a,b){var c,d=a.length;for(c=0;d>c;c++)if(b(a[c]))return c;return-1}function i(a){var b,c=a.length,d=new Array(c);for(b=0;c>b;b++)d[b]=a[b];return d}function j(a,b){var c,d,e,f=a.length;if(b>=0&&f>b){if(1===f)return[];for(c=new Array(f-1),d=0,e=0;f>d;d++)d!==b&&(c[e]=a[d],e++);return c}return a}function k(a,b){return j(a,h(a,b))}function l(a,b){var c,d=a.length,e=new Array(d);for(c=0;d>c;c++)e[c]=b(a[c]);return e}function m(a,b){var c,d=a.length;for(c=0;d>c;c++)b(a[c])}function n(a,b){var c,d=a.length;for(c=0;d>c;c++)a[c]=b}function o(a,b,c){return a.length>b?Array.prototype.slice.call(a,b):c}function p(a,b,c){var d,e=Math.min(c,a.length+1),f=a.length-e+1,g=new Array(e);for(d=f;e>d;d++)g[d-f]=a[d];return g[e-1]=b,g}function q(a,b){switch(b){case 0:return function(b){return a()};case 1:return function(b){return a(b[0])};case 2:return function(b){return a(b[0],b[1])};case 3:return function(b){return a(b[0],b[1],b[2])};case 4:return function(b){return a(b[0],b[1],b[2],b[3])};default:return function(b){return a.apply(null,b)}}}function r(a,b,c){var d=c?c.length:0;if(null==b)switch(d){case 0:return a();case 1:return a(c[0]);case 2:return a(c[0],c[1]);case 3:return a(c[0],c[1],c[2]);case 4:return a(c[0],c[1],c[2],c[3]);default:return a.apply(null,c)}else switch(d){case 0:return a.call(b);default:return a.apply(b,c)}}function s(a,b,c){return a&&b in a?a[b]:c}function t(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function u(a){var b=function(){};return b.prototype=a,new b}function v(a){var b,c,d=arguments.length;for(b=1;d>b;b++)for(c in arguments[b])a[c]=arguments[b][c];return a}function w(a,b){var c,d=arguments.length;for(a.prototype=u(b.prototype),a.prototype.constructor=a,c=2;d>c;c++)v(a.prototype,arguments[c]);return a}function x(){}function y(a){return a}function z(a,b){return b}function A(a,b){return a===b}function B(a,b){return[a,b]}function C(){return!1}function D(){return!0}function E(a,b,c){var d="Method `"+a+"` is deprecated, and to be removed in v3.0.0.";return b&&(d+="\nUse `"+b+"` instead."),d+="\nTo disable all warnings like this set `Kefir.DEPRECATION_WARNINGS = false`.",function(){return ha.DEPRECATION_WARNINGS&&oa(d),c.apply(this,arguments)}}function F(a){return"function"==typeof a}function G(a,b){function c(a,b){N.call(this),this._wait=a,this._intervalId=null;var c=this;this._$onTick=function(){c._onTick()},this._init(b)}w(c,N,{_name:a,_init:function(a){},_free:function(){},_onTick:function(){},_onActivation:function(){this._intervalId=setInterval(this._$onTick,this._wait)},_onDeactivation:function(){null!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=null)},_clear:function(){N.prototype._clear.call(this),this._$onTick=null,this._free()}},b),ha[a]=function(a){return new c(a,o(arguments,1,[]))}}function H(a,b,c){function d(c){function d(b,d){c.call(this),this._source=b,this._name=b._name+"."+a,this._init(d);var e=this;this._$handleAny=function(a){e._handleAny(a)}}return w(d,c,{_clear:function(){c.prototype._clear.call(this),this._source=null,this._$handleAny=null,this._free()}},b),d}c=v({streamMethod:function(a,b){return function(){return new a(this,arguments)}},propertyMethod:function(a,b){return function(){return new b(this,arguments)}}},c||{}),b=v({_init:function(a){},_free:function(){},_handleValue:function(a,b){this._send(ka,a,b)},_handleError:function(a,b){this._send(la,a,b)},_handleEnd:function(a,b){this._send(ja,null,b)},_handleAny:function(a){switch(a.type){case ka:this._handleValue(a.value,a.current);break;case la:this._handleError(a.value,a.current);break;case ja:this._handleEnd(a.value,a.current)}},_onActivation:function(){this._source.onAny(this._$handleAny)},_onDeactivation:function(){this._source.offAny(this._$handleAny)}},b||{});var e=d(N),f=d(O);c.streamMethod&&(N.prototype[a]=c.streamMethod(e,f)),c.propertyMethod&&(O.prototype[a]=c.propertyMethod(e,f))}function I(a,b){function c(c){function d(b,d,e){c.call(this),this._primary=b,this._secondary=d,this._name=b._name+"."+a,this._lastSecondary=ia;var f=this;this._$handleSecondaryAny=function(a){f._handleSecondaryAny(a)},this._$handlePrimaryAny=function(a){f._handlePrimaryAny(a)},this._init(e)}return w(d,c,{_clear:function(){c.prototype._clear.call(this),this._primary=null,this._secondary=null,this._lastSecondary=null,this._$handleSecondaryAny=null,this._$handlePrimaryAny=null,this._free()}},b),d}b=v({_init:function(a){},_free:function(){},_handlePrimaryValue:function(a,b){this._send(ka,a,b)},_handlePrimaryError:function(a,b){this._send(la,a,b)},_handlePrimaryEnd:function(a,b){this._send(ja,null,b)},_handleSecondaryValue:function(a,b){this._lastSecondary=a},_handleSecondaryError:function(a,b){this._send(la,a,b)},_handleSecondaryEnd:function(a,b){},_handlePrimaryAny:function(a){switch(a.type){case ka:this._handlePrimaryValue(a.value,a.current);break;case la:this._handlePrimaryError(a.value,a.current);break;case ja:this._handlePrimaryEnd(a.value,a.current)}},_handleSecondaryAny:function(a){switch(a.type){case ka:this._handleSecondaryValue(a.value,a.current);break;case la:this._handleSecondaryError(a.value,a.current);break;case ja:this._handleSecondaryEnd(a.value,a.current),this._removeSecondary()}},_removeSecondary:function(){null!==this._secondary&&(this._secondary.offAny(this._$handleSecondaryAny),this._$handleSecondaryAny=null,this._secondary=null)},_onActivation:function(){null!==this._secondary&&this._secondary.onAny(this._$handleSecondaryAny),this._alive&&this._primary.onAny(this._$handlePrimaryAny)},_onDeactivation:function(){null!==this._secondary&&this._secondary.offAny(this._$handleSecondaryAny),this._primary.offAny(this._$handlePrimaryAny)}},b||{});var d=c(N),e=c(O);N.prototype[a]=function(a){return new d(this,a,o(arguments,1,[]))},O.prototype[a]=function(a){return new e(this,a,o(arguments,1,[]))}}function J(a,b,c){a===ma?b(c):a===c.type&&(a===ka||a===la?b(c.value):b())}function K(){this._items=[]}function L(a,b,c){return{type:a,value:b,current:!!c}}function M(){this._dispatcher=new K,this._active=!1,this._alive=!0}function N(){M.call(this)}function O(){M.call(this),this._currentEvent=null}function P(a){if(N.call(this),this._queueLim=s(a,"queueLim",0),this._concurLim=s(a,"concurLim",-1),this._drop=s(a,"drop","new"),0===this._concurLim)throw new Error("options.concurLim can't be 0");var b=this;this._$handleSubAny=function(a){b._handleSubAny(a)},this._queue=[],this._curSources=[],this._activating=!1,this._bindedEndHandlers=[]}function Q(a){P.call(this),0===a.length?this._send(ja):this._addAll(a),this._initialised=!0}function R(a){P.call(this,{concurLim:1,queueLim:-1}),0===a.length?this._send(ja):this._addAll(a),this._initialised=!0}function S(){P.call(this)}function T(){P.call(this)}function U(a,b,c){P.call(this,c),this._source=a,this._fn=b||y,this._mainEnded=!1,this._lastCurrent=null;var d=this;this._$handleMainSource=function(a){d._handleMainSource(a)}}function V(a,b){if(N.call(this),0===a.length)this._send(ja);else{this._buffers=l(a,function(a){return pa(a)?i(a):[]}),this._sources=l(a,function(a){return pa(a)?ha.never():a}),this._combinator=b?q(b,this._sources.length):y,this._aliveCount=0,this._bindedHandlers=Array(this._sources.length);for(var c=0;c<this._sources.length;c++)this._bindedHandlers[c]=this._bindHandleAny(c)}}function W(a){for(var b,c=0;c<a.length;c++)void 0!==a[c]&&(void 0===b||b.index<a[c].index)&&(b=a[c]);return b.error}function X(a,b,c){if(N.call(this),0===a.length)this._send(ja);else{this._activeCount=a.length,this._sources=e(a,b),this._combinator=c?q(c,this._sources.length):y,this._aliveCount=0,this._latestValues=new Array(this._sources.length),this._latestErrors=new Array(this._sources.length),n(this._latestValues,ia),this._activating=!1,this._emitAfterActivation=!1,this._endAfterActivation=!1,this._latestErrorIndex=0,this._bindedHandlers=Array(this._sources.length);for(var d=0;d<this._sources.length;d++)this._bindedHandlers[d]=this._bindHandleAny(d)}}function Y(a,b){return function(){return new a(this,arguments)}}function Z(a,b){return function(){return new b(this,arguments)}}function $(a){return{"@@transducer/step":function(b,c){return a._send(ka,c,a._forcedCurrent),null},"@@transducer/result":function(b){return a._send(ja,null,a._forcedCurrent),null}}}function _(a){return{convert:!0,value:a}}function aa(a){return{convert:!0,error:a}}function ba(a){N.call(this),this._fn=a,this._unsubscribe=null}function ca(){N.call(this)}function da(a){O.call(this),this._send(ka,a),this._send(ja)}function ea(a){O.call(this),this._send(la,a),this._send(ja)}function fa(a){N.call(this),this._generator=a,this._source=null,this._inLoop=!1,this._activating=!1,this._iteration=0;var b=this;this._$handleAny=function(a){b._handleAny(a)}}function ga(a,b,c){return ha.stream(function(d){var e=c?function(){d.emit(r(c,this,arguments))}:d.emit;return a(e),function(){b(e)}})}var ha={},ia=["<nothing>"],ja="end",ka="value",la="error",ma="any",na=Date.now?function(){return Date.now()}:function(){return(new Date).getTime()},oa=void 0!==typeof console&&F(console.log)?function(a){console.log(a)}:x;ha.DEPRECATION_WARNINGS=!0;var pa=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},qa=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};qa(arguments)||(qa=function(a){return!(!a||!t(a,"callee"))}),v(K.prototype,{add:function(a,b){return this._items=e(this._items,[{type:a,fn:b}]),this._items.length},remove:function(a,b){return this._items=k(this._items,function(c){return c.type===a&&c.fn===b}),this._items.length},dispatch:function(a){for(var b=this._items,c=0;c<b.length;c++)J(b[c].type,b[c].fn,a)}});var ra=L(ja,void 0,!0);ha.Observable=M,v(M.prototype,{_name:"observable",_onActivation:function(){},_onDeactivation:function(){},_setActive:function(a){this._active!==a&&(this._active=a,a?this._onActivation():this._onDeactivation())},_clear:function(){this._setActive(!1),this._alive=!1,this._dispatcher=null},_send:function(a,b,c){this._alive&&(this._dispatcher.dispatch(L(a,b,c)),a===ja&&this._clear())},_on:function(a,b){return this._alive?(this._dispatcher.add(a,b),this._setActive(!0)):J(a,b,ra),this},_off:function(a,b){if(this._alive){var c=this._dispatcher.remove(a,b);0===c&&this._setActive(!1)}return this},onValue:function(a){return this._on(ka,a)},onError:function(a){return this._on(la,a)},onEnd:function(a){return this._on(ja,a)},onAny:function(a){return this._on(ma,a)},offValue:function(a){return this._off(ka,a)},offError:function(a){return this._off(la,a)},offEnd:function(a){return this._off(ja,a)},offAny:function(a){return this._off(ma,a)}}),M.prototype.toString=function(){return"["+this._name+"]"},ha.Stream=N,w(N,M,{_name:"stream"}),ha.Property=O,w(O,M,{_name:"property",_send:function(a,b,c){this._alive&&(c||this._dispatcher.dispatch(L(a,b)),(a===ka||a===la)&&(this._currentEvent=L(a,b,!0)),a===ja&&this._clear())},_on:function(a,b){return this._alive&&(this._dispatcher.add(a,b),this._setActive(!0)),null!==this._currentEvent&&J(a,b,this._currentEvent),this._alive||J(a,b,ra),this}}),M.prototype.log=function(a){a=a||this.toString();var b=function(b){var c="<"+b.type+(b.current?":current":"")+">";b.type===ka||b.type===la?console.log(a,c,b.value):console.log(a,c)};return this.__logHandlers||(this.__logHandlers=[]),this.__logHandlers.push({name:a,handler:b}),this.onAny(b),this},M.prototype.offLog=function(a){if(a=a||this.toString(),this.__logHandlers){var b=h(this.__logHandlers,function(b){return b.name===a});if(-1!==b){var c=this.__logHandlers[b].handler;this.__logHandlers.splice(b,1),this.offAny(c)}}return this},G("withInterval",{_init:function(a){this._fn=a[0];var b=this;this._emitter={emit:function(a){b._send(ka,a)},error:function(a){b._send(la,a)},end:function(){b._send(ja)},emitEvent:function(a){b._send(a.type,a.value)}}},_free:function(){this._fn=null,this._emitter=null},_onTick:function(){this._fn(this._emitter)}}),G("fromPoll",{_init:function(a){this._fn=a[0]},_free:function(){this._fn=null},_onTick:function(){this._send(ka,this._fn())}}),G("interval",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send(ka,this._x)}}),G("sequentially",{_init:function(a){this._xs=i(a[0]),0===this._xs.length&&this._send(ja)},_free:function(){this._xs=null},_onTick:function(){switch(this._xs.length){case 1:this._send(ka,this._xs[0]),this._send(ja);break;default:this._send(ka,this._xs.shift())}}}),G("repeatedly",{_init:function(a){this._xs=i(a[0]),this._i=-1},_onTick:function(){this._xs.length>0&&(this._i=(this._i+1)%this._xs.length,this._send(ka,this._xs[this._i]))}}),ha.repeatedly=E("Kefir.repeatedly()","Kefir.repeat(() => Kefir.sequentially(...)})",ha.repeatedly),G("later",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send(ka,this._x),this._send(ja)}}),w(P,N,{_name:"abstractPool",_add:function(a,b){b=b||y,-1===this._concurLim||this._curSources.length<this._concurLim?this._addToCur(b(a)):-1===this._queueLim||this._queue.length<this._queueLim?this._addToQueue(b(a)):"old"===this._drop&&(this._removeOldest(),this._add(b(a)))},_addAll:function(a){var b=this;m(a,function(a){b._add(a)})},_remove:function(a){-1===this._removeCur(a)&&this._removeQueue(a)},_addToQueue:function(a){this._queue=e(this._queue,[a])},_addToCur:function(a){this._curSources=e(this._curSources,[a]),this._active&&this._subscribe(a)},_subscribe:function(a){var b=this,c=function(){b._removeCur(a)};this._bindedEndHandlers.push({obs:a,handler:c}),a.onAny(this._$handleSubAny),this._active&&a.onEnd(c)},_unsubscribe:function(a){a.offAny(this._$handleSubAny);var b=h(this._bindedEndHandlers,function(b){return b.obs===a});if(-1!==b){var c=this._bindedEndHandlers[b].handler;this._bindedEndHandlers.splice(b,1),a.offEnd(c)}},_handleSubAny:function(a){(a.type===ka||a.type===la)&&this._send(a.type,a.value,a.current&&this._activating)},_removeQueue:function(a){var b=g(this._queue,a);return this._queue=j(this._queue,b),b},_removeCur:function(a){this._active&&this._unsubscribe(a);var b=g(this._curSources,a);return this._curSources=j(this._curSources,b),-1!==b&&(0!==this._queue.length?this._pullQueue():0===this._curSources.length&&this._onEmpty()),b},_removeOldest:function(){this._removeCur(this._curSources[0])},_pullQueue:function(){0!==this._queue.length&&(this._queue=i(this._queue),this._addToCur(this._queue.shift()))},_onActivation:function(){var a,b=this._curSources;for(this._activating=!0,a=0;a<b.length;a++)this._active&&this._subscribe(b[a]);this._activating=!1},_onDeactivation:function(){var a,b=this._curSources;for(a=0;a<b.length;a++)this._unsubscribe(b[a])},_isEmpty:function(){return 0===this._curSources.length},_onEmpty:function(){},_clear:function(){N.prototype._clear.call(this),this._queue=null,this._curSources=null,this._$handleSubAny=null,this._bindedEndHandlers=null}});var sa={_onEmpty:function(){this._initialised&&this._send(ja,null,this._activating)}};w(Q,P,v({_name:"merge"},sa)),ha.merge=function(a){return new Q(a)},M.prototype.merge=function(a){return ha.merge([this,a])},w(R,P,v({_name:"concat"},sa)),ha.concat=function(a){return new R(a)},M.prototype.concat=function(a){return ha.concat([this,a])},ha.Pool=S,w(S,P,{_name:"pool",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this}}),ha.pool=function(){return new S},ha.Bus=T,w(T,P,{_name:"bus",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this},emit:function(a){return this._send(ka,a),this},error:function(a){return this._send(la,a),this},end:function(){return this._send(ja),this},emitEvent:function(a){this._send(a.type,a.value)}}),ha.bus=E("Kefir.bus()","Kefir.pool() or Kefir.stream()",function(){return new T}),w(U,P,{_onActivation:function(){P.prototype._onActivation.call(this),this._active&&(this._activating=!0,this._source.onAny(this._$handleMainSource),this._activating=!1)},_onDeactivation:function(){P.prototype._onDeactivation.call(this),this._source.offAny(this._$handleMainSource)},_handleMainSource:function(a){a.type===ka&&(a.current&&this._lastCurrent===a.value||this._add(a.value,this._fn),this._lastCurrent=a.value),a.type===la&&this._send(la,a.value,a.current),a.type===ja&&(this._isEmpty()?this._send(ja,null,a.current):this._mainEnded=!0)},_onEmpty:function(){this._mainEnded&&this._send(ja)},_clear:function(){P.prototype._clear.call(this),this._source=null,this._lastCurrent=null,this._$handleMainSource=null}}),M.prototype.flatMap=function(a){return new U(this,a).setName(this,"flatMap")},M.prototype.flatMapLatest=function(a){return new U(this,a,{concurLim:1,drop:"old"}).setName(this,"flatMapLatest")},M.prototype.flatMapFirst=function(a){return new U(this,a,{concurLim:1}).setName(this,"flatMapFirst")},M.prototype.flatMapConcat=function(a){return new U(this,a,{queueLim:-1,concurLim:1}).setName(this,"flatMapConcat")},M.prototype.flatMapConcurLimit=function(a,b){var c;return 0===b?c=ha.never():(0>b&&(b=-1),c=new U(this,a,{queueLim:-1,concurLim:b})),c.setName(this,"flatMapConcurLimit")},w(V,N,{_name:"zip",_onActivation:function(){var a,b=this._sources.length;for(this._drainArrays(),this._aliveCount=b,a=0;b>a;a++)this._active&&this._sources[a].onAny(this._bindedHandlers[a])},_onDeactivation:function(){for(var a=0;a<this._sources.length;a++)this._sources[a].offAny(this._bindedHandlers[a])},_emit:function(a){for(var b=new Array(this._buffers.length),c=0;c<this._buffers.length;c++)b[c]=this._buffers[c].shift();this._send(ka,this._combinator(b),a)},_isFull:function(){for(var a=0;a<this._buffers.length;a++)if(0===this._buffers[a].length)return!1;return!0},_emitIfFull:function(a){this._isFull()&&this._emit(a)},_drainArrays:function(){for(;this._isFull();)this._emit(!0)},_bindHandleAny:function(a){var b=this;return function(c){b._handleAny(a,c)}},_handleAny:function(a,b){b.type===ka&&(this._buffers[a].push(b.value),this._emitIfFull(b.current)),b.type===la&&this._send(la,b.value,b.current),b.type===ja&&(this._aliveCount--,0===this._aliveCount&&this._send(ja,null,b.current))},_clear:function(){N.prototype._clear.call(this),this._sources=null,this._buffers=null,this._combinator=null,this._bindedHandlers=null}}),ha.zip=function(a,b){return new V(a,b)},M.prototype.zip=function(a,b){return new V([this,a],b)},w(X,N,{_name:"combine",_onActivation:function(){var a,b=this._sources.length;for(this._aliveCount=this._activeCount,this._activating=!0,a=0;b>a;a++)this._sources[a].onAny(this._bindedHandlers[a]);this._activating=!1,this._emitAfterActivation&&(this._emitAfterActivation=!1,this._emitIfFull(!0)),this._endAfterActivation&&this._send(ja,null,!0)},_onDeactivation:function(){var a,b=this._sources.length;for(a=0;b>a;a++)this._sources[a].offAny(this._bindedHandlers[a])},_emitIfFull:function(a){for(var b=!0,c=!1,d=this._latestValues.length,e=new Array(d),f=new Array(d),g=0;d>g;g++)e[g]=this._latestValues[g],f[g]=this._latestErrors[g],e[g]===ia&&(b=!1),void 0!==f[g]&&(c=!0);b&&this._send(ka,this._combinator(e),a),c&&this._send(la,W(f),a)},_bindHandleAny:function(a){var b=this;return function(c){b._handleAny(a,c)}},_handleAny:function(a,b){b.type===ka||b.type===la?(b.type===ka&&(this._latestValues[a]=b.value,this._latestErrors[a]=void 0),b.type===la&&(this._latestValues[a]=ia,this._latestErrors[a]={index:this._latestErrorIndex++,error:b.value}),a<this._activeCount&&(this._activating?this._emitAfterActivation=!0:this._emitIfFull(b.current))):a<this._activeCount&&(this._aliveCount--,0===this._aliveCount&&(this._activating?this._endAfterActivation=!0:this._send(ja,null,b.current)))},_clear:function(){N.prototype._clear.call(this),this._sources=null,this._latestValues=null,this._latestErrors=null,this._combinator=null,this._bindedHandlers=null}}),ha.combine=function(a,b,c){return F(b)&&(c=b,b=null),new X(a,b||[],c)},M.prototype.combine=function(a,b){return ha.combine([this,a],b)},ha.sampledBy=E("Kefir.sampledBy()","Kefir.combine(active, passive, combinator)",function(a,b,c){var d=c;if(a.length>0){var e=a.length;d=function(){var a=f(arguments,e);return c?r(c,null,a):a}}return new X(b,a,d).setName("sampledBy")}),M.prototype.sampledBy=function(a,b){var c;return b&&(c=function(a,c){return b(c,a)}),new X([a],[this],c||z).setName(this,"sampledBy")},H("toProperty",{_init:function(a){if(void 0!==a[0]){if(!F(a[0]))throw new TypeError("The .toProperty method must be called with no args or with a function as an argument");this._getInitialCurrent=a[0]}else this._getInitialCurrent=null},_onActivation:function(){if(null!==this._getInitialCurrent){var a=this._getInitialCurrent;this._send(ka,a(),!0)}this._source.onAny(this._$handleAny)}},{propertyMethod:Z,streamMethod:Z}),H("changes",{_handleValue:function(a,b){b||this._send(ka,a)},_handleError:function(a,b){b||this._send(la,a)}},{streamMethod:Y,propertyMethod:Y}),H("withHandler",{_init:function(a){this._handler=a[0],this._forcedCurrent=!1;var b=this;this._emitter={emit:function(a){b._send(ka,a,b._forcedCurrent)},error:function(a){b._send(la,a,b._forcedCurrent)},end:function(){b._send(ja,null,b._forcedCurrent)},emitEvent:function(a){b._send(a.type,a.value,b._forcedCurrent)}}},_free:function(){this._handler=null,this._emitter=null},_handleAny:function(a){this._forcedCurrent=a.current,this._handler(this._emitter,a),this._forcedCurrent=!1}}),H("flatten",{_init:function(a){this._fn=a[0]?a[0]:y},_free:function(){this._fn=null},_handleValue:function(a,b){for(var c=this._fn(a),d=0;d<c.length;d++)this._send(ka,c[d],b)}}),H("transduce",{_init:function(a){this._xform=a[0]($(this))},_free:function(){this._xform=null},_handleValue:function(a,b){this._forcedCurrent=b,null!==this._xform["@@transducer/step"](null,a)&&this._xform["@@transducer/result"](null),this._forcedCurrent=!1},_handleEnd:function(a,b){this._forcedCurrent=b,this._xform["@@transducer/result"](null),this._forcedCurrent=!1}}),H("map",{_init:function(a){this._fn=a[0]||y},_free:function(){this._fn=null},_handleValue:function(a,b){this._send(ka,this._fn(a),b)}}),H("mapErrors",{_init:function(a){this._fn=a[0]||y},_free:function(){this._fn=null},_handleError:function(a,b){this._send(la,this._fn(a),b)}}),H("errorsToValues",{_init:function(a){this._fn=a[0]||_},_free:function(){this._fn=null},_handleError:function(a,b){var c=this._fn(a),d=c.convert?ka:la,e=c.convert?c.value:a;this._send(d,e,b)}}),H("valuesToErrors",{_init:function(a){this._fn=a[0]||aa},_free:function(){this._fn=null},_handleValue:function(a,b){var c=this._fn(a),d=c.convert?la:ka,e=c.convert?c.error:a;this._send(d,e,b)}}),H("filter",{_init:function(a){this._fn=a[0]||y},_free:function(){this._fn=null},_handleValue:function(a,b){this._fn(a)&&this._send(ka,a,b)}}),H("filterErrors",{_init:function(a){this._fn=a[0]||y},_free:function(){this._fn=null},_handleError:function(a,b){this._fn(a)&&this._send(la,a,b)}}),H("takeWhile",{_init:function(a){this._fn=a[0]||y},_free:function(){this._fn=null},_handleValue:function(a,b){this._fn(a)?this._send(ka,a,b):this._send(ja,null,b)}}),H("take",{_init:function(a){this._n=a[0],this._n<=0&&this._send(ja)},_handleValue:function(a,b){this._n--,this._send(ka,a,b),0===this._n&&this._send(ja,null,b)}}),H("skip",{_init:function(a){this._n=Math.max(0,a[0])},_handleValue:function(a,b){0===this._n?this._send(ka,a,b):this._n--}}),H("skipDuplicates",{_init:function(a){this._fn=a[0]||A,this._prev=ia},_free:function(){this._fn=null,this._prev=null},_handleValue:function(a,b){this._prev!==ia&&this._fn(this._prev,a)||(this._prev=a,this._send(ka,a,b))}}),H("skipWhile",{_init:function(a){this._fn=a[0]||y,this._skip=!0},_free:function(){this._fn=null},_handleValue:function(a,b){return this._skip?void(this._fn(a)||(this._skip=!1,this._fn=null,this._send(ka,a,b))):void this._send(ka,a,b)}}),H("diff",{_init:function(a){this._fn=a[0]||B,this._prev=a.length>1?a[1]:ia},_free:function(){this._prev=null,this._fn=null},_handleValue:function(a,b){this._prev!==ia&&this._send(ka,this._fn(this._prev,a),b),this._prev=a}}),H("scan",{_init:function(a){this._fn=a[0],a.length>1&&this._send(ka,a[1],!0)},_free:function(){this._fn=null},_handleValue:function(a,b){null!==this._currentEvent&&this._currentEvent.type!==la&&(a=this._fn(this._currentEvent.value,a)),this._send(ka,a,b)}},{streamMethod:Z}),H("reduce",{_init:function(a){this._fn=a[0],this._result=a.length>1?a[1]:ia},_free:function(){this._fn=null,this._result=null},_handleValue:function(a){this._result=this._result===ia?a:this._fn(this._result,a)},_handleEnd:function(a,b){this._result!==ia&&this._send(ka,this._result,b),this._send(ja,null,b)}}),H("beforeEnd",{_init:function(a){this._fn=a[0]},_free:function(){this._fn=null},_handleEnd:function(a,b){this._send(ka,this._fn(),b),this._send(ja,null,b)}}),H("skipValues",{_handleValue:function(){}}),H("skipErrors",{_handleError:function(){}}),H("skipEnd",{_handleEnd:function(){}}),H("endOnError",{_handleError:function(a,b){this._send(la,a,b),this._send(ja,null,b)}}),H("slidingWindow",{_init:function(a){this._max=a[0],this._min=a[1]||0,this._buff=[]},_free:function(){this._buff=null},_handleValue:function(a,b){this._buff=p(this._buff,a,this._max),this._buff.length>=this._min&&this._send(ka,this._buff,b)}}),H("bufferWhile",{_init:function(a){this._fn=a[0]||y,this._flushOnEnd=s(a[1],"flushOnEnd",!0),this._buff=[]},_free:function(){this._buff=null},_flush:function(a){null!==this._buff&&0!==this._buff.length&&(this._send(ka,this._buff,a),this._buff=[])},_handleValue:function(a,b){this._buff.push(a),this._fn(a)||this._flush(b)},_handleEnd:function(a,b){this._flushOnEnd&&this._flush(b),this._send(ja,null,b)}}),H("debounce",{_init:function(a){this._wait=Math.max(0,a[0]),this._immediate=s(a[1],"immediate",!1),this._lastAttempt=0,this._timeoutId=null,this._laterValue=null,this._endLater=!1;var b=this;this._$later=function(){b._later()}},_free:function(){this._laterValue=null,this._$later=null},_handleValue:function(a,b){b?this._send(ka,a,b):(this._lastAttempt=na(),this._immediate&&!this._timeoutId&&this._send(ka,a),this._timeoutId||(this._timeoutId=setTimeout(this._$later,this._wait)),this._immediate||(this._laterValue=a))},_handleEnd:function(a,b){b?this._send(ja,null,b):this._timeoutId&&!this._immediate?this._endLater=!0:this._send(ja)},_later:function(){var a=na()-this._lastAttempt;a<this._wait&&a>=0?this._timeoutId=setTimeout(this._$later,this._wait-a):(this._timeoutId=null,this._immediate||(this._send(ka,this._laterValue),this._laterValue=null),this._endLater&&this._send(ja))}}),H("throttle",{_init:function(a){this._wait=Math.max(0,a[0]),this._leading=s(a[1],"leading",!0),this._trailing=s(a[1],"trailing",!0),this._trailingValue=null,this._timeoutId=null,this._endLater=!1,this._lastCallTime=0;var b=this;this._$trailingCall=function(){b._trailingCall()}},_free:function(){this._trailingValue=null,this._$trailingCall=null},_handleValue:function(a,b){if(b)this._send(ka,a,b);else{var c=na();0!==this._lastCallTime||this._leading||(this._lastCallTime=c);var d=this._wait-(c-this._lastCallTime);0>=d?(this._cancelTraling(),this._lastCallTime=c,this._send(ka,a)):this._trailing&&(this._cancelTraling(),this._trailingValue=a,this._timeoutId=setTimeout(this._$trailingCall,d))}},_handleEnd:function(a,b){b?this._send(ja,null,b):this._timeoutId?this._endLater=!0:this._send(ja)},_cancelTraling:function(){null!==this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=null)},_trailingCall:function(){this._send(ka,this._trailingValue),this._timeoutId=null,this._trailingValue=null,this._lastCallTime=this._leading?na():0,this._endLater&&this._send(ja)}}),H("delay",{_init:function(a){this._wait=Math.max(0,a[0]),this._buff=[];var b=this;this._$shiftBuff=function(){b._send(ka,b._buff.shift())}},_free:function(){this._buff=null,this._$shiftBuff=null},_handleValue:function(a,b){b?this._send(ka,a,b):(this._buff.push(a),setTimeout(this._$shiftBuff,this._wait))},_handleEnd:function(a,b){if(b)this._send(ja,null,b);else{var c=this;setTimeout(function(){c._send(ja)},this._wait)}}}),w(ba,N,{_name:"stream",_onActivation:function(){var a=this,b=!0,c={emit:function(c){a._send(ka,c,b)},error:function(c){a._send(la,c,b)},end:function(){a._send(ja,null,b)},emitEvent:function(c){a._send(c.type,c.value,b)}};this._unsubscribe=this._fn(c)||null,this._active||null===this._unsubscribe||(this._unsubscribe(),this._unsubscribe=null),b=!1},_onDeactivation:function(){null!==this._unsubscribe&&(this._unsubscribe(),this._unsubscribe=null)},_clear:function(){N.prototype._clear.call(this),this._fn=null}}),ha.stream=function(a){return new ba(a)},w(ca,N,{_name:"emitter",emit:function(a){return this._send(ka,a),this},error:function(a){return this._send(la,a),this},end:function(){return this._send(ja),this},emitEvent:function(a){this._send(a.type,a.value)}}),ha.emitter=E("Kefir.emitter()","Kefir.stream()",function(){return new ca}),ha.Emitter=ca;var ta=new N;ta._send(ja),ta._name="never",ha.never=function(){return ta},w(da,O,{_name:"constant"}),ha.constant=function(a){return new da(a)},w(ea,O,{_name:"constantError"}),ha.constantError=function(a){return new ea(a)},w(fa,N,{_name:"repeat",_handleAny:function(a){a.type===ja?(this._source=null,this._startLoop()):this._send(a.type,a.value,this._activating)},_startLoop:function(){if(!this._inLoop){for(this._inLoop=!0;null===this._source&&this._alive&&this._active;)this._source=this._generator(this._iteration++),this._source?this._source.onAny(this._$handleAny):this._send(ja);this._inLoop=!1}},_onActivation:function(){this._activating=!0,this._source?this._source.onAny(this._$handleAny):this._startLoop(),this._activating=!1},_onDeactivation:function(){this._source&&this._source.offAny(this._$handleAny)},_clear:function(){N.prototype._clear.call(this),this._generator=null,this._source=null,this._$handleAny=null}}),ha.repeat=function(a){return new fa(a)},M.prototype.setName=function(a,b){return this._name=b?a._name+"."+b:a,this},M.prototype.mapTo=E(".mapTo()",".map(() => value)",function(a){return this.map(function(){return a}).setName(this,"mapTo")}),M.prototype.pluck=E(".pluck()",".map((v) => v.prop)",function(a){return this.map(function(b){return b[a]}).setName(this,"pluck")}),M.prototype.invoke=E(".invoke()",".map((v) => v.method())",function(a){var b=o(arguments,1);return this.map(b?function(c){return r(c[a],c,b)}:function(b){return b[a]()}).setName(this,"invoke")}),M.prototype.timestamp=E(".timestamp()",".map((v) => {value: v, time: (new Date).getTime()})",function(){return this.map(function(a){return{value:a,time:na()}}).setName(this,"timestamp")}),M.prototype.tap=E(".tap()",".map((v) => {fn(v); return v})",function(a){return this.map(function(b){return a(b),b}).setName(this,"tap")}),ha.and=E("Kefir.and()","Kefir.combine([a, b], (a, b) => a && b)",function(a){return ha.combine(a,b).setName("and")}),M.prototype.and=E(".and()",".combine(other, (a, b) => a && b)",function(a){return this.combine(a,b).setName("and")}),ha.or=E("Kefir.or()","Kefir.combine([a, b], (a, b) => a || b)",function(a){return ha.combine(a,c).setName("or")}),M.prototype.or=E(".or()",".combine(other, (a, b) => a || b)",function(a){return this.combine(a,c).setName("or")}),M.prototype.not=E(".not()",".map(v => !v)",function(){return this.map(d).setName(this,"not")}),M.prototype.awaiting=function(a){return ha.merge([this.map(D),a.map(C)]).skipDuplicates().toProperty(C).setName(this,"awaiting")},ha.fromCallback=function(a){var b=!1;return ha.stream(function(c){b||(a(function(a){
c.emit(a),c.end()}),b=!0)}).setName("fromCallback")},ha.fromNodeCallback=function(a){var b=!1;return ha.stream(function(c){b||(a(function(a,b){a?c.error(a):c.emit(b),c.end()}),b=!0)}).setName("fromNodeCallback")},ha.fromPromise=function(a){var b=!1;return ha.stream(function(c){if(!b){var d=function(a){c.emit(a),c.end()},e=function(a){c.error(a),c.end()},f=a.then(d,e);f&&F(f.done)&&f.done(),b=!0}}).toProperty().setName("fromPromise")},ha.fromSubUnsub=E(".fromSubUnsub()","Kefir.stream()",ga);var ua=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"]];ha.fromEvents=function(a,b,c){for(var d,e,f,g=0;g<ua.length;g++)if(d=ua[g],F(a[d[0]])&&F(a[d[1]])){e=d[0],f=d[1];break}if(void 0===e)throw new Error("target don't support any of addEventListener/removeEventListener, addListener/removeListener, on/off method pair");return ga(function(c){a[e](b,c)},function(c){a[f](b,c)},c).setName("fromEvents")};var va={_init:function(a){this._buff=[],this._flushOnEnd=s(a[0],"flushOnEnd",!0)},_free:function(){this._buff=null},_flush:function(a){null!==this._buff&&0!==this._buff.length&&(this._send(ka,this._buff,a),this._buff=[])},_handlePrimaryEnd:function(a,b){this._flushOnEnd&&this._flush(b),this._send(ja,null,b)}};I("bufferBy",v({_onActivation:function(){this._primary.onAny(this._$handlePrimaryAny),this._alive&&null!==this._secondary&&this._secondary.onAny(this._$handleSecondaryAny)},_handlePrimaryValue:function(a,b){this._buff.push(a)},_handleSecondaryValue:function(a,b){this._flush(b)},_handleSecondaryEnd:function(a,b){this._flushOnEnd||this._send(ja,null,b)}},va)),I("bufferWhileBy",v({_handlePrimaryValue:function(a,b){this._buff.push(a),this._lastSecondary===ia||this._lastSecondary||this._flush(b)},_handleSecondaryEnd:function(a,b){this._flushOnEnd||this._lastSecondary!==ia&&!this._lastSecondary||this._send(ja,null,b)}},va)),I("filterBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==ia&&this._lastSecondary&&this._send(ka,a,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary!==ia&&this._lastSecondary||this._send(ja,null,b)}}),I("skipUntilBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==ia&&this._send(ka,a,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary===ia&&this._send(ja,null,b)}}),I("takeUntilBy",{_handleSecondaryValue:function(a,b){this._send(ja,null,b)}}),I("takeWhileBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==ia&&this._send(ka,a,b)},_handleSecondaryValue:function(a,b){this._lastSecondary=a,this._lastSecondary||this._send(ja,null,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary===ia&&this._send(ja,null,b)}}),I("skipWhileBy",{_init:function(){this._hasFalseyFromSecondary=!1},_handlePrimaryValue:function(a,b){this._hasFalseyFromSecondary&&this._send(ka,a,b)},_handleSecondaryValue:function(a,b){this._hasFalseyFromSecondary=this._hasFalseyFromSecondary||!a},_handleSecondaryEnd:function(a,b){this._hasFalseyFromSecondary||this._send(ja,null,b)}}),"function"==typeof define&&define.amd?(define([],function(){return ha}),a.Kefir=ha):"object"==typeof module&&"object"==typeof exports?(module.exports=ha,ha.Kefir=ha):a.Kefir=ha}(this);
!function(a){"use strict";function b(){for(var a=0;a<arguments.length;a++)if(!arguments[a])return arguments[a];return arguments[a-1]}function c(){for(var a=0;a<arguments.length;a++)if(arguments[a])return arguments[a];return arguments[a-1]}function d(a){return!a}function e(a,b){var c,d,e,f;if(0===a.length)return b;if(0===b.length)return a;for(f=0,c=new Array(a.length+b.length),d=a.length,e=0;d>e;e++,f++)c[f]=a[e];for(d=b.length,e=0;d>e;e++,f++)c[f]=b[e];return c}function f(a,b){var c,d=a.length,e=new Array(d);for(c=0;d>c;c++)e[(c+b)%d]=a[c];return e}function g(a,b){var c,d=a.length;for(c=0;d>c;c++)if(a[c]===b)return c;return-1}function h(a,b){var c,d=a.length;for(c=0;d>c;c++)if(b(a[c]))return c;return-1}function i(a){var b,c=a.length,d=new Array(c);for(b=0;c>b;b++)d[b]=a[b];return d}function j(a,b){var c,d,e,f=a.length;if(b>=0&&f>b){if(1===f)return[];for(c=new Array(f-1),d=0,e=0;f>d;d++)d!==b&&(c[e]=a[d],e++);return c}return a}function k(a,b){return j(a,h(a,b))}function l(a,b){var c,d=a.length,e=new Array(d);for(c=0;d>c;c++)e[c]=b(a[c]);return e}function m(a,b){var c,d=a.length;for(c=0;d>c;c++)b(a[c])}function n(a,b){var c,d=a.length;for(c=0;d>c;c++)a[c]=b}function o(a,b,c){return a.length>b?Array.prototype.slice.call(a,b):c}function p(a,b,c){var d,e=Math.min(c,a.length+1),f=a.length-e+1,g=new Array(e);for(d=f;e>d;d++)g[d-f]=a[d];return g[e-1]=b,g}function q(a,b){switch(b){case 0:return function(b){return a()};case 1:return function(b){return a(b[0])};case 2:return function(b){return a(b[0],b[1])};case 3:return function(b){return a(b[0],b[1],b[2])};case 4:return function(b){return a(b[0],b[1],b[2],b[3])};default:return function(b){return a.apply(null,b)}}}function r(a,b,c){var d=c?c.length:0;if(null==b)switch(d){case 0:return a();case 1:return a(c[0]);case 2:return a(c[0],c[1]);case 3:return a(c[0],c[1],c[2]);case 4:return a(c[0],c[1],c[2],c[3]);default:return a.apply(null,c)}else switch(d){case 0:return a.call(b);default:return a.apply(b,c)}}function s(a,b,c){return a&&b in a?a[b]:c}function t(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function u(a){var b=function(){};return b.prototype=a,new b}function v(a){var b,c,d=arguments.length;for(b=1;d>b;b++)for(c in arguments[b])a[c]=arguments[b][c];return a}function w(a,b){var c,d=arguments.length;for(a.prototype=u(b.prototype),a.prototype.constructor=a,c=2;d>c;c++)v(a.prototype,arguments[c]);return a}function x(){}function y(a){return a}function z(a,b){return b}function A(a,b){return a===b}function B(a,b){return[a,b]}function C(){return!1}function D(){return!0}function E(a,b,c){var d="Method `"+a+"` is deprecated, and to be removed in v3.0.0.";return b&&(d+="\nUse `"+b+"` instead."),d+="\nTo disable all warnings like this set `Kefir.DEPRECATION_WARNINGS = false`.",function(){return ha.DEPRECATION_WARNINGS&&oa(d),c.apply(this,arguments)}}function F(a){return"function"==typeof a}function G(a,b){function c(a,b){N.call(this),this._wait=a,this._intervalId=null;var c=this;this._$onTick=function(){c._onTick()},this._init(b)}w(c,N,{_name:a,_init:function(a){},_free:function(){},_onTick:function(){},_onActivation:function(){this._intervalId=setInterval(this._$onTick,this._wait)},_onDeactivation:function(){null!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=null)},_clear:function(){N.prototype._clear.call(this),this._$onTick=null,this._free()}},b),ha[a]=function(a){return new c(a,o(arguments,1,[]))}}function H(a,b,c){function d(c){function d(b,d){c.call(this),this._source=b,this._name=b._name+"."+a,this._init(d);var e=this;this._$handleAny=function(a){e._handleAny(a)}}return w(d,c,{_clear:function(){c.prototype._clear.call(this),this._source=null,this._$handleAny=null,this._free()}},b),d}c=v({streamMethod:function(a,b){return function(){return new a(this,arguments)}},propertyMethod:function(a,b){return function(){return new b(this,arguments)}}},c||{}),b=v({_init:function(a){},_free:function(){},_handleValue:function(a,b){this._send(ka,a,b)},_handleError:function(a,b){this._send(la,a,b)},_handleEnd:function(a,b){this._send(ja,null,b)},_handleAny:function(a){switch(a.type){case ka:this._handleValue(a.value,a.current);break;case la:this._handleError(a.value,a.current);break;case ja:this._handleEnd(a.value,a.current)}},_onActivation:function(){this._source.onAny(this._$handleAny)},_onDeactivation:function(){this._source.offAny(this._$handleAny)}},b||{});var e=d(N),f=d(O);c.streamMethod&&(N.prototype[a]=c.streamMethod(e,f)),c.propertyMethod&&(O.prototype[a]=c.propertyMethod(e,f))}function I(a,b){function c(c){function d(b,d,e){c.call(this),this._primary=b,this._secondary=d,this._name=b._name+"."+a,this._lastSecondary=ia;var f=this;this._$handleSecondaryAny=function(a){f._handleSecondaryAny(a)},this._$handlePrimaryAny=function(a){f._handlePrimaryAny(a)},this._init(e)}return w(d,c,{_clear:function(){c.prototype._clear.call(this),this._primary=null,this._secondary=null,this._lastSecondary=null,this._$handleSecondaryAny=null,this._$handlePrimaryAny=null,this._free()}},b),d}b=v({_init:function(a){},_free:function(){},_handlePrimaryValue:function(a,b){this._send(ka,a,b)},_handlePrimaryError:function(a,b){this._send(la,a,b)},_handlePrimaryEnd:function(a,b){this._send(ja,null,b)},_handleSecondaryValue:function(a,b){this._lastSecondary=a},_handleSecondaryError:function(a,b){this._send(la,a,b)},_handleSecondaryEnd:function(a,b){},_handlePrimaryAny:function(a){switch(a.type){case ka:this._handlePrimaryValue(a.value,a.current);break;case la:this._handlePrimaryError(a.value,a.current);break;case ja:this._handlePrimaryEnd(a.value,a.current)}},_handleSecondaryAny:function(a){switch(a.type){case ka:this._handleSecondaryValue(a.value,a.current);break;case la:this._handleSecondaryError(a.value,a.current);break;case ja:this._handleSecondaryEnd(a.value,a.current),this._removeSecondary()}},_removeSecondary:function(){null!==this._secondary&&(this._secondary.offAny(this._$handleSecondaryAny),this._$handleSecondaryAny=null,this._secondary=null)},_onActivation:function(){null!==this._secondary&&this._secondary.onAny(this._$handleSecondaryAny),this._alive&&this._primary.onAny(this._$handlePrimaryAny)},_onDeactivation:function(){null!==this._secondary&&this._secondary.offAny(this._$handleSecondaryAny),this._primary.offAny(this._$handlePrimaryAny)}},b||{});var d=c(N),e=c(O);N.prototype[a]=function(a){return new d(this,a,o(arguments,1,[]))},O.prototype[a]=function(a){return new e(this,a,o(arguments,1,[]))}}function J(a,b,c){a===ma?b(c):a===c.type&&(a===ka||a===la?b(c.value):b())}function K(){this._items=[]}function L(a,b,c){return{type:a,value:b,current:!!c}}function M(){this._dispatcher=new K,this._active=!1,this._alive=!0}function N(){M.call(this)}function O(){M.call(this),this._currentEvent=null}function P(a){if(N.call(this),this._queueLim=s(a,"queueLim",0),this._concurLim=s(a,"concurLim",-1),this._drop=s(a,"drop","new"),0===this._concurLim)throw new Error("options.concurLim can't be 0");var b=this;this._$handleSubAny=function(a){b._handleSubAny(a)},this._queue=[],this._curSources=[],this._activating=!1,this._bindedEndHandlers=[]}function Q(a){P.call(this),0===a.length?this._send(ja):this._addAll(a),this._initialised=!0}function R(a){P.call(this,{concurLim:1,queueLim:-1}),0===a.length?this._send(ja):this._addAll(a),this._initialised=!0}function S(){P.call(this)}function T(){P.call(this)}function U(a,b,c){P.call(this,c),this._source=a,this._fn=b||y,this._mainEnded=!1,this._lastCurrent=null;var d=this;this._$handleMainSource=function(a){d._handleMainSource(a)}}function V(a,b){if(N.call(this),0===a.length)this._send(ja);else{this._buffers=l(a,function(a){return pa(a)?i(a):[]}),this._sources=l(a,function(a){return pa(a)?ha.never():a}),this._combinator=b?q(b,this._sources.length):y,this._aliveCount=0,this._bindedHandlers=Array(this._sources.length);for(var c=0;c<this._sources.length;c++)this._bindedHandlers[c]=this._bindHandleAny(c)}}function W(a){for(var b,c=0;c<a.length;c++)void 0!==a[c]&&(void 0===b||b.index<a[c].index)&&(b=a[c]);return b.error}function X(a,b,c){if(N.call(this),0===a.length)this._send(ja);else{this._activeCount=a.length,this._sources=e(a,b),this._combinator=c?q(c,this._sources.length):y,this._aliveCount=0,this._latestValues=new Array(this._sources.length),this._latestErrors=new Array(this._sources.length),n(this._latestValues,ia),this._activating=!1,this._emitAfterActivation=!1,this._endAfterActivation=!1,this._latestErrorIndex=0,this._bindedHandlers=Array(this._sources.length);for(var d=0;d<this._sources.length;d++)this._bindedHandlers[d]=this._bindHandleAny(d)}}function Y(a,b){return function(){return new a(this,arguments)}}function Z(a,b){return function(){return new b(this,arguments)}}function $(a){return{"@@transducer/step":function(b,c){return a._send(ka,c,a._forcedCurrent),null},"@@transducer/result":function(b){return a._send(ja,null,a._forcedCurrent),null}}}function _(a){return{convert:!0,value:a}}function aa(a){return{convert:!0,error:a}}function ba(a){N.call(this),this._fn=a,this._unsubscribe=null}function ca(){N.call(this)}function da(a){O.call(this),this._send(ka,a),this._send(ja)}function ea(a){O.call(this),this._send(la,a),this._send(ja)}function fa(a){N.call(this),this._generator=a,this._source=null,this._inLoop=!1,this._activating=!1,this._iteration=0;var b=this;this._$handleAny=function(a){b._handleAny(a)}}function ga(a,b,c){return ha.stream(function(d){var e=c?function(){d.emit(r(c,this,arguments))}:d.emit;return a(e),function(){b(e)}})}var ha={},ia=["<nothing>"],ja="end",ka="value",la="error",ma="any",na=Date.now?function(){return Date.now()}:function(){return(new Date).getTime()},oa=void 0!==typeof console&&F(console.log)?function(a){console.log(a)}:x;ha.DEPRECATION_WARNINGS=!0;var pa=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},qa=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};qa(arguments)||(qa=function(a){return!(!a||!t(a,"callee"))}),v(K.prototype,{add:function(a,b){return this._items=e(this._items,[{type:a,fn:b}]),this._items.length},remove:function(a,b){return this._items=k(this._items,function(c){return c.type===a&&c.fn===b}),this._items.length},dispatch:function(a){for(var b=this._items,c=0;c<b.length;c++)J(b[c].type,b[c].fn,a)}});var ra=L(ja,void 0,!0);ha.Observable=M,v(M.prototype,{_name:"observable",_onActivation:function(){},_onDeactivation:function(){},_setActive:function(a){this._active!==a&&(this._active=a,a?this._onActivation():this._onDeactivation())},_clear:function(){this._setActive(!1),this._alive=!1,this._dispatcher=null},_send:function(a,b,c){this._alive&&(this._dispatcher.dispatch(L(a,b,c)),a===ja&&this._clear())},_on:function(a,b){return this._alive?(this._dispatcher.add(a,b),this._setActive(!0)):J(a,b,ra),this},_off:function(a,b){if(this._alive){var c=this._dispatcher.remove(a,b);0===c&&this._setActive(!1)}return this},onValue:function(a){return this._on(ka,a)},onError:function(a){return this._on(la,a)},onEnd:function(a){return this._on(ja,a)},onAny:function(a){return this._on(ma,a)},offValue:function(a){return this._off(ka,a)},offError:function(a){return this._off(la,a)},offEnd:function(a){return this._off(ja,a)},offAny:function(a){return this._off(ma,a)}}),M.prototype.toString=function(){return"["+this._name+"]"},ha.Stream=N,w(N,M,{_name:"stream"}),ha.Property=O,w(O,M,{_name:"property",_send:function(a,b,c){this._alive&&(c||this._dispatcher.dispatch(L(a,b)),(a===ka||a===la)&&(this._currentEvent=L(a,b,!0)),a===ja&&this._clear())},_on:function(a,b){return this._alive&&(this._dispatcher.add(a,b),this._setActive(!0)),null!==this._currentEvent&&J(a,b,this._currentEvent),this._alive||J(a,b,ra),this}}),M.prototype.log=function(a){a=a||this.toString();var b=function(b){var c="<"+b.type+(b.current?":current":"")+">";b.type===ka||b.type===la?console.log(a,c,b.value):console.log(a,c)};return this.__logHandlers||(this.__logHandlers=[]),this.__logHandlers.push({name:a,handler:b}),this.onAny(b),this},M.prototype.offLog=function(a){if(a=a||this.toString(),this.__logHandlers){var b=h(this.__logHandlers,function(b){return b.name===a});if(-1!==b){var c=this.__logHandlers[b].handler;this.__logHandlers.splice(b,1),this.offAny(c)}}return this},G("withInterval",{_init:function(a){this._fn=a[0];var b=this;this._emitter={emit:function(a){b._send(ka,a)},error:function(a){b._send(la,a)},end:function(){b._send(ja)},emitEvent:function(a){b._send(a.type,a.value)}}},_free:function(){this._fn=null,this._emitter=null},_onTick:function(){this._fn(this._emitter)}}),G("fromPoll",{_init:function(a){this._fn=a[0]},_free:function(){this._fn=null},_onTick:function(){this._send(ka,this._fn())}}),G("interval",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send(ka,this._x)}}),G("sequentially",{_init:function(a){this._xs=i(a[0]),0===this._xs.length&&this._send(ja)},_free:function(){this._xs=null},_onTick:function(){switch(this._xs.length){case 1:this._send(ka,this._xs[0]),this._send(ja);break;default:this._send(ka,this._xs.shift())}}}),G("repeatedly",{_init:function(a){this._xs=i(a[0]),this._i=-1},_onTick:function(){this._xs.length>0&&(this._i=(this._i+1)%this._xs.length,this._send(ka,this._xs[this._i]))}}),ha.repeatedly=E("Kefir.repeatedly()","Kefir.repeat(() => Kefir.sequentially(...)})",ha.repeatedly),G("later",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send(ka,this._x),this._send(ja)}}),w(P,N,{_name:"abstractPool",_add:function(a,b){b=b||y,-1===this._concurLim||this._curSources.length<this._concurLim?this._addToCur(b(a)):-1===this._queueLim||this._queue.length<this._queueLim?this._addToQueue(b(a)):"old"===this._drop&&(this._removeOldest(),this._add(b(a)))},_addAll:function(a){var b=this;m(a,function(a){b._add(a)})},_remove:function(a){-1===this._removeCur(a)&&this._removeQueue(a)},_addToQueue:function(a){this._queue=e(this._queue,[a])},_addToCur:function(a){this._curSources=e(this._curSources,[a]),this._active&&this._subscribe(a)},_subscribe:function(a){var b=this,c=function(){b._removeCur(a)};this._bindedEndHandlers.push({obs:a,handler:c}),a.onAny(this._$handleSubAny),this._active&&a.onEnd(c)},_unsubscribe:function(a){a.offAny(this._$handleSubAny);var b=h(this._bindedEndHandlers,function(b){return b.obs===a});if(-1!==b){var c=this._bindedEndHandlers[b].handler;this._bindedEndHandlers.splice(b,1),a.offEnd(c)}},_handleSubAny:function(a){(a.type===ka||a.type===la)&&this._send(a.type,a.value,a.current&&this._activating)},_removeQueue:function(a){var b=g(this._queue,a);return this._queue=j(this._queue,b),b},_removeCur:function(a){this._active&&this._unsubscribe(a);var b=g(this._curSources,a);return this._curSources=j(this._curSources,b),-1!==b&&(0!==this._queue.length?this._pullQueue():0===this._curSources.length&&this._onEmpty()),b},_removeOldest:function(){this._removeCur(this._curSources[0])},_pullQueue:function(){0!==this._queue.length&&(this._queue=i(this._queue),this._addToCur(this._queue.shift()))},_onActivation:function(){var a,b=this._curSources;for(this._activating=!0,a=0;a<b.length;a++)this._active&&this._subscribe(b[a]);this._activating=!1},_onDeactivation:function(){var a,b=this._curSources;for(a=0;a<b.length;a++)this._unsubscribe(b[a])},_isEmpty:function(){return 0===this._curSources.length},_onEmpty:function(){},_clear:function(){N.prototype._clear.call(this),this._queue=null,this._curSources=null,this._$handleSubAny=null,this._bindedEndHandlers=null}});var sa={_onEmpty:function(){this._initialised&&this._send(ja,null,this._activating)}};w(Q,P,v({_name:"merge"},sa)),ha.merge=function(a){return new Q(a)},M.prototype.merge=function(a){return ha.merge([this,a])},w(R,P,v({_name:"concat"},sa)),ha.concat=function(a){return new R(a)},M.prototype.concat=function(a){return ha.concat([this,a])},ha.Pool=S,w(S,P,{_name:"pool",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this}}),ha.pool=function(){return new S},ha.Bus=T,w(T,P,{_name:"bus",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this},emit:function(a){return this._send(ka,a),this},error:function(a){return this._send(la,a),this},end:function(){return this._send(ja),this},emitEvent:function(a){this._send(a.type,a.value)}}),ha.bus=E("Kefir.bus()","Kefir.pool() or Kefir.stream()",function(){return new T}),w(U,P,{_onActivation:function(){P.prototype._onActivation.call(this),this._active&&(this._activating=!0,this._source.onAny(this._$handleMainSource),this._activating=!1)},_onDeactivation:function(){P.prototype._onDeactivation.call(this),this._source.offAny(this._$handleMainSource)},_handleMainSource:function(a){a.type===ka&&(a.current&&this._lastCurrent===a.value||this._add(a.value,this._fn),this._lastCurrent=a.value),a.type===la&&this._send(la,a.value,a.current),a.type===ja&&(this._isEmpty()?this._send(ja,null,a.current):this._mainEnded=!0)},_onEmpty:function(){this._mainEnded&&this._send(ja)},_clear:function(){P.prototype._clear.call(this),this._source=null,this._lastCurrent=null,this._$handleMainSource=null}}),M.prototype.flatMap=function(a){return new U(this,a).setName(this,"flatMap")},M.prototype.flatMapLatest=function(a){return new U(this,a,{concurLim:1,drop:"old"}).setName(this,"flatMapLatest")},M.prototype.flatMapFirst=function(a){return new U(this,a,{concurLim:1}).setName(this,"flatMapFirst")},M.prototype.flatMapConcat=function(a){return new U(this,a,{queueLim:-1,concurLim:1}).setName(this,"flatMapConcat")},M.prototype.flatMapConcurLimit=function(a,b){var c;return 0===b?c=ha.never():(0>b&&(b=-1),c=new U(this,a,{queueLim:-1,concurLim:b})),c.setName(this,"flatMapConcurLimit")},w(V,N,{_name:"zip",_onActivation:function(){var a,b=this._sources.length;for(this._drainArrays(),this._aliveCount=b,a=0;b>a;a++)this._active&&this._sources[a].onAny(this._bindedHandlers[a])},_onDeactivation:function(){for(var a=0;a<this._sources.length;a++)this._sources[a].offAny(this._bindedHandlers[a])},_emit:function(a){for(var b=new Array(this._buffers.length),c=0;c<this._buffers.length;c++)b[c]=this._buffers[c].shift();this._send(ka,this._combinator(b),a)},_isFull:function(){for(var a=0;a<this._buffers.length;a++)if(0===this._buffers[a].length)return!1;return!0},_emitIfFull:function(a){this._isFull()&&this._emit(a)},_drainArrays:function(){for(;this._isFull();)this._emit(!0)},_bindHandleAny:function(a){var b=this;return function(c){b._handleAny(a,c)}},_handleAny:function(a,b){b.type===ka&&(this._buffers[a].push(b.value),this._emitIfFull(b.current)),b.type===la&&this._send(la,b.value,b.current),b.type===ja&&(this._aliveCount--,0===this._aliveCount&&this._send(ja,null,b.current))},_clear:function(){N.prototype._clear.call(this),this._sources=null,this._buffers=null,this._combinator=null,this._bindedHandlers=null}}),ha.zip=function(a,b){return new V(a,b)},M.prototype.zip=function(a,b){return new V([this,a],b)},w(X,N,{_name:"combine",_onActivation:function(){var a,b=this._sources.length;for(this._aliveCount=this._activeCount,this._activating=!0,a=0;b>a;a++)this._sources[a].onAny(this._bindedHandlers[a]);this._activating=!1,this._emitAfterActivation&&(this._emitAfterActivation=!1,this._emitIfFull(!0)),this._endAfterActivation&&this._send(ja,null,!0)},_onDeactivation:function(){var a,b=this._sources.length;for(a=0;b>a;a++)this._sources[a].offAny(this._bindedHandlers[a])},_emitIfFull:function(a){for(var b=!0,c=!1,d=this._latestValues.length,e=new Array(d),f=new Array(d),g=0;d>g;g++)e[g]=this._latestValues[g],f[g]=this._latestErrors[g],e[g]===ia&&(b=!1),void 0!==f[g]&&(c=!0);b&&this._send(ka,this._combinator(e),a),c&&this._send(la,W(f),a)},_bindHandleAny:function(a){var b=this;return function(c){b._handleAny(a,c)}},_handleAny:function(a,b){b.type===ka||b.type===la?(b.type===ka&&(this._latestValues[a]=b.value,this._latestErrors[a]=void 0),b.type===la&&(this._latestValues[a]=ia,this._latestErrors[a]={index:this._latestErrorIndex++,error:b.value}),a<this._activeCount&&(this._activating?this._emitAfterActivation=!0:this._emitIfFull(b.current))):a<this._activeCount&&(this._aliveCount--,0===this._aliveCount&&(this._activating?this._endAfterActivation=!0:this._send(ja,null,b.current)))},_clear:function(){N.prototype._clear.call(this),this._sources=null,this._latestValues=null,this._latestErrors=null,this._combinator=null,this._bindedHandlers=null}}),ha.combine=function(a,b,c){return F(b)&&(c=b,b=null),new X(a,b||[],c)},M.prototype.combine=function(a,b){return ha.combine([this,a],b)},ha.sampledBy=E("Kefir.sampledBy()","Kefir.combine(active, passive, combinator)",function(a,b,c){var d=c;if(a.length>0){var e=a.length;d=function(){var a=f(arguments,e);return c?r(c,null,a):a}}return new X(b,a,d).setName("sampledBy")}),M.prototype.sampledBy=function(a,b){var c;return b&&(c=function(a,c){return b(c,a)}),new X([a],[this],c||z).setName(this,"sampledBy")},H("toProperty",{_init:function(a){if(void 0!==a[0]){if(!F(a[0]))throw new TypeError("The .toProperty method must be called with no args or with a function as an argument");this._getInitialCurrent=a[0]}else this._getInitialCurrent=null},_onActivation:function(){if(null!==this._getInitialCurrent){var a=this._getInitialCurrent;this._send(ka,a(),!0)}this._source.onAny(this._$handleAny)}},{propertyMethod:Z,streamMethod:Z}),H("changes",{_handleValue:function(a,b){b||this._send(ka,a)},_handleError:function(a,b){b||this._send(la,a)}},{streamMethod:Y,propertyMethod:Y}),H("withHandler",{_init:function(a){this._handler=a[0],this._forcedCurrent=!1;var b=this;this._emitter={emit:function(a){b._send(ka,a,b._forcedCurrent)},error:function(a){b._send(la,a,b._forcedCurrent)},end:function(){b._send(ja,null,b._forcedCurrent)},emitEvent:function(a){b._send(a.type,a.value,b._forcedCurrent)}}},_free:function(){this._handler=null,this._emitter=null},_handleAny:function(a){this._forcedCurrent=a.current,this._handler(this._emitter,a),this._forcedCurrent=!1}}),H("flatten",{_init:function(a){this._fn=a[0]?a[0]:y},_free:function(){this._fn=null},_handleValue:function(a,b){for(var c=this._fn(a),d=0;d<c.length;d++)this._send(ka,c[d],b)}}),H("transduce",{_init:function(a){this._xform=a[0]($(this))},_free:function(){this._xform=null},_handleValue:function(a,b){this._forcedCurrent=b,null!==this._xform["@@transducer/step"](null,a)&&this._xform["@@transducer/result"](null),this._forcedCurrent=!1},_handleEnd:function(a,b){this._forcedCurrent=b,this._xform["@@transducer/result"](null),this._forcedCurrent=!1}}),H("last",{_init:function(){this._lastValue=ia},_free:function(){this._lastValue=null},_handleValue:function(a){this._lastValue=a},_handleEnd:function(a,b){this._lastValue!==ia&&this._send(ka,this._lastValue,b),this._send(ja,null,b)}}),H("map",{_init:function(a){this._fn=a[0]||y},_free:function(){this._fn=null},_handleValue:function(a,b){this._send(ka,this._fn(a),b)}}),H("mapErrors",{_init:function(a){this._fn=a[0]||y},_free:function(){this._fn=null},_handleError:function(a,b){this._send(la,this._fn(a),b)}}),H("errorsToValues",{_init:function(a){this._fn=a[0]||_},_free:function(){this._fn=null},_handleError:function(a,b){var c=this._fn(a),d=c.convert?ka:la,e=c.convert?c.value:a;this._send(d,e,b)}}),H("valuesToErrors",{_init:function(a){this._fn=a[0]||aa},_free:function(){this._fn=null},_handleValue:function(a,b){var c=this._fn(a),d=c.convert?la:ka,e=c.convert?c.error:a;this._send(d,e,b)}}),H("filter",{_init:function(a){this._fn=a[0]||y},_free:function(){this._fn=null},_handleValue:function(a,b){this._fn(a)&&this._send(ka,a,b)}}),H("filterErrors",{_init:function(a){this._fn=a[0]||y},_free:function(){this._fn=null},_handleError:function(a,b){this._fn(a)&&this._send(la,a,b)}}),H("takeWhile",{_init:function(a){this._fn=a[0]||y},_free:function(){this._fn=null},_handleValue:function(a,b){this._fn(a)?this._send(ka,a,b):this._send(ja,null,b)}}),H("take",{_init:function(a){this._n=a[0],this._n<=0&&this._send(ja)},_handleValue:function(a,b){this._n--,this._send(ka,a,b),0===this._n&&this._send(ja,null,b)}}),H("skip",{_init:function(a){this._n=Math.max(0,a[0])},_handleValue:function(a,b){0===this._n?this._send(ka,a,b):this._n--}}),H("skipDuplicates",{_init:function(a){this._fn=a[0]||A,this._prev=ia},_free:function(){this._fn=null,this._prev=null},_handleValue:function(a,b){this._prev!==ia&&this._fn(this._prev,a)||(this._prev=a,this._send(ka,a,b))}}),H("skipWhile",{_init:function(a){this._fn=a[0]||y,this._skip=!0},_free:function(){this._fn=null},_handleValue:function(a,b){return this._skip?void(this._fn(a)||(this._skip=!1,this._fn=null,this._send(ka,a,b))):void this._send(ka,a,b)}}),H("diff",{_init:function(a){this._fn=a[0]||B,this._prev=a.length>1?a[1]:ia},_free:function(){this._prev=null,this._fn=null},_handleValue:function(a,b){this._prev!==ia&&this._send(ka,this._fn(this._prev,a),b),this._prev=a}}),H("scan",{_init:function(a){this._fn=a[0],a.length>1&&this._send(ka,a[1],!0)},_free:function(){this._fn=null},_handleValue:function(a,b){null!==this._currentEvent&&this._currentEvent.type!==la&&(a=this._fn(this._currentEvent.value,a)),this._send(ka,a,b)}},{streamMethod:Z}),H("reduce",{_init:function(a){this._fn=a[0],this._result=a.length>1?a[1]:ia},_free:function(){this._fn=null,this._result=null},_handleValue:function(a){this._result=this._result===ia?a:this._fn(this._result,a)},_handleEnd:function(a,b){this._result!==ia&&this._send(ka,this._result,b),this._send(ja,null,b)}}),N.prototype.reduce=E(".reduce(fn, seed)",".scan(fn, seed).last()",N.prototype.reduce),O.prototype.reduce=E(".reduce(fn, seed)",".scan(fn, seed).last()",O.prototype.reduce),H("beforeEnd",{_init:function(a){this._fn=a[0]},_free:function(){this._fn=null},_handleEnd:function(a,b){this._send(ka,this._fn(),b),this._send(ja,null,b)}}),H("skipValues",{_handleValue:function(){}}),H("skipErrors",{_handleError:function(){}}),H("skipEnd",{_handleEnd:function(){}}),H("endOnError",{_handleError:function(a,b){this._send(la,a,b),this._send(ja,null,b)}}),H("slidingWindow",{_init:function(a){this._max=a[0],this._min=a[1]||0,this._buff=[]},_free:function(){this._buff=null},_handleValue:function(a,b){this._buff=p(this._buff,a,this._max),this._buff.length>=this._min&&this._send(ka,this._buff,b)}}),H("bufferWhile",{_init:function(a){this._fn=a[0]||y,this._flushOnEnd=s(a[1],"flushOnEnd",!0),this._buff=[]},_free:function(){this._buff=null},_flush:function(a){null!==this._buff&&0!==this._buff.length&&(this._send(ka,this._buff,a),this._buff=[])},_handleValue:function(a,b){this._buff.push(a),this._fn(a)||this._flush(b)},_handleEnd:function(a,b){this._flushOnEnd&&this._flush(b),this._send(ja,null,b)}}),H("debounce",{_init:function(a){this._wait=Math.max(0,a[0]),this._immediate=s(a[1],"immediate",!1),this._lastAttempt=0,this._timeoutId=null,this._laterValue=null,this._endLater=!1;var b=this;this._$later=function(){b._later()}},_free:function(){this._laterValue=null,this._$later=null},_handleValue:function(a,b){b?this._send(ka,a,b):(this._lastAttempt=na(),this._immediate&&!this._timeoutId&&this._send(ka,a),this._timeoutId||(this._timeoutId=setTimeout(this._$later,this._wait)),this._immediate||(this._laterValue=a))},_handleEnd:function(a,b){b?this._send(ja,null,b):this._timeoutId&&!this._immediate?this._endLater=!0:this._send(ja)},_later:function(){var a=na()-this._lastAttempt;a<this._wait&&a>=0?this._timeoutId=setTimeout(this._$later,this._wait-a):(this._timeoutId=null,this._immediate||(this._send(ka,this._laterValue),this._laterValue=null),this._endLater&&this._send(ja))}}),H("throttle",{_init:function(a){this._wait=Math.max(0,a[0]),this._leading=s(a[1],"leading",!0),this._trailing=s(a[1],"trailing",!0),this._trailingValue=null,this._timeoutId=null,this._endLater=!1,this._lastCallTime=0;var b=this;this._$trailingCall=function(){b._trailingCall()}},_free:function(){this._trailingValue=null,this._$trailingCall=null},_handleValue:function(a,b){if(b)this._send(ka,a,b);else{var c=na();0!==this._lastCallTime||this._leading||(this._lastCallTime=c);var d=this._wait-(c-this._lastCallTime);0>=d?(this._cancelTraling(),this._lastCallTime=c,this._send(ka,a)):this._trailing&&(this._cancelTraling(),this._trailingValue=a,this._timeoutId=setTimeout(this._$trailingCall,d))}},_handleEnd:function(a,b){b?this._send(ja,null,b):this._timeoutId?this._endLater=!0:this._send(ja)},_cancelTraling:function(){null!==this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=null)},_trailingCall:function(){this._send(ka,this._trailingValue),this._timeoutId=null,this._trailingValue=null,this._lastCallTime=this._leading?na():0,this._endLater&&this._send(ja)}}),H("delay",{_init:function(a){this._wait=Math.max(0,a[0]),this._buff=[];var b=this;this._$shiftBuff=function(){b._send(ka,b._buff.shift())}},_free:function(){this._buff=null,this._$shiftBuff=null},_handleValue:function(a,b){b?this._send(ka,a,b):(this._buff.push(a),setTimeout(this._$shiftBuff,this._wait))},_handleEnd:function(a,b){if(b)this._send(ja,null,b);else{var c=this;setTimeout(function(){c._send(ja)},this._wait)}}}),w(ba,N,{_name:"stream",_onActivation:function(){var a=this,b=!0,c={emit:function(c){a._send(ka,c,b)},error:function(c){a._send(la,c,b)},end:function(){a._send(ja,null,b)},emitEvent:function(c){a._send(c.type,c.value,b)}};this._unsubscribe=this._fn(c)||null,this._active||null===this._unsubscribe||(this._unsubscribe(),this._unsubscribe=null),b=!1},_onDeactivation:function(){null!==this._unsubscribe&&(this._unsubscribe(),this._unsubscribe=null)},_clear:function(){N.prototype._clear.call(this),this._fn=null}}),ha.stream=function(a){return new ba(a)},w(ca,N,{_name:"emitter",emit:function(a){return this._send(ka,a),this},error:function(a){return this._send(la,a),this},end:function(){return this._send(ja),this},emitEvent:function(a){this._send(a.type,a.value)}}),ha.emitter=E("Kefir.emitter()","Kefir.stream()",function(){return new ca}),ha.Emitter=ca;var ta=new N;ta._send(ja),ta._name="never",ha.never=function(){return ta},w(da,O,{_name:"constant"}),ha.constant=function(a){return new da(a)},w(ea,O,{_name:"constantError"}),ha.constantError=function(a){return new ea(a)},w(fa,N,{_name:"repeat",_handleAny:function(a){a.type===ja?(this._source=null,this._startLoop()):this._send(a.type,a.value,this._activating)},_startLoop:function(){if(!this._inLoop){for(this._inLoop=!0;null===this._source&&this._alive&&this._active;)this._source=this._generator(this._iteration++),this._source?this._source.onAny(this._$handleAny):this._send(ja);this._inLoop=!1}},_onActivation:function(){this._activating=!0,this._source?this._source.onAny(this._$handleAny):this._startLoop(),this._activating=!1},_onDeactivation:function(){this._source&&this._source.offAny(this._$handleAny)},_clear:function(){N.prototype._clear.call(this),this._generator=null,this._source=null,this._$handleAny=null}}),ha.repeat=function(a){return new fa(a)},M.prototype.setName=function(a,b){return this._name=b?a._name+"."+b:a,this},M.prototype.mapTo=E(".mapTo()",".map(() => value)",function(a){return this.map(function(){return a}).setName(this,"mapTo")}),M.prototype.pluck=E(".pluck()",".map((v) => v.prop)",function(a){return this.map(function(b){return b[a]}).setName(this,"pluck")}),M.prototype.invoke=E(".invoke()",".map((v) => v.method())",function(a){var b=o(arguments,1);return this.map(b?function(c){return r(c[a],c,b)}:function(b){return b[a]()}).setName(this,"invoke")}),M.prototype.timestamp=E(".timestamp()",".map((v) => {value: v, time: (new Date).getTime()})",function(){return this.map(function(a){return{value:a,time:na()}}).setName(this,"timestamp")}),M.prototype.tap=E(".tap()",".map((v) => {fn(v); return v})",function(a){return this.map(function(b){return a(b),b}).setName(this,"tap")}),ha.and=E("Kefir.and()","Kefir.combine([a, b], (a, b) => a && b)",function(a){return ha.combine(a,b).setName("and")}),M.prototype.and=E(".and()",".combine(other, (a, b) => a && b)",function(a){return this.combine(a,b).setName("and")}),ha.or=E("Kefir.or()","Kefir.combine([a, b], (a, b) => a || b)",function(a){return ha.combine(a,c).setName("or")}),M.prototype.or=E(".or()",".combine(other, (a, b) => a || b)",function(a){
return this.combine(a,c).setName("or")}),M.prototype.not=E(".not()",".map(v => !v)",function(){return this.map(d).setName(this,"not")}),M.prototype.awaiting=function(a){return ha.merge([this.map(D),a.map(C)]).skipDuplicates().toProperty(C).setName(this,"awaiting")},ha.fromCallback=function(a){var b=!1;return ha.stream(function(c){b||(a(function(a){c.emit(a),c.end()}),b=!0)}).setName("fromCallback")},ha.fromNodeCallback=function(a){var b=!1;return ha.stream(function(c){b||(a(function(a,b){a?c.error(a):c.emit(b),c.end()}),b=!0)}).setName("fromNodeCallback")},ha.fromPromise=function(a){var b=!1;return ha.stream(function(c){if(!b){var d=function(a){c.emit(a),c.end()},e=function(a){c.error(a),c.end()},f=a.then(d,e);f&&F(f.done)&&f.done(),b=!0}}).toProperty().setName("fromPromise")},ha.fromSubUnsub=E(".fromSubUnsub()","Kefir.stream()",ga);var ua=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"]];ha.fromEvents=function(a,b,c){for(var d,e,f,g=0;g<ua.length;g++)if(d=ua[g],F(a[d[0]])&&F(a[d[1]])){e=d[0],f=d[1];break}if(void 0===e)throw new Error("target don't support any of addEventListener/removeEventListener, addListener/removeListener, on/off method pair");return ga(function(c){a[e](b,c)},function(c){a[f](b,c)},c).setName("fromEvents")};var va={_init:function(a){this._buff=[],this._flushOnEnd=s(a[0],"flushOnEnd",!0)},_free:function(){this._buff=null},_flush:function(a){null!==this._buff&&0!==this._buff.length&&(this._send(ka,this._buff,a),this._buff=[])},_handlePrimaryEnd:function(a,b){this._flushOnEnd&&this._flush(b),this._send(ja,null,b)}};I("bufferBy",v({_onActivation:function(){this._primary.onAny(this._$handlePrimaryAny),this._alive&&null!==this._secondary&&this._secondary.onAny(this._$handleSecondaryAny)},_handlePrimaryValue:function(a,b){this._buff.push(a)},_handleSecondaryValue:function(a,b){this._flush(b)},_handleSecondaryEnd:function(a,b){this._flushOnEnd||this._send(ja,null,b)}},va)),I("bufferWhileBy",v({_handlePrimaryValue:function(a,b){this._buff.push(a),this._lastSecondary===ia||this._lastSecondary||this._flush(b)},_handleSecondaryEnd:function(a,b){this._flushOnEnd||this._lastSecondary!==ia&&!this._lastSecondary||this._send(ja,null,b)}},va)),I("filterBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==ia&&this._lastSecondary&&this._send(ka,a,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary!==ia&&this._lastSecondary||this._send(ja,null,b)}}),I("skipUntilBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==ia&&this._send(ka,a,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary===ia&&this._send(ja,null,b)}}),I("takeUntilBy",{_handleSecondaryValue:function(a,b){this._send(ja,null,b)}}),I("takeWhileBy",{_handlePrimaryValue:function(a,b){this._lastSecondary!==ia&&this._send(ka,a,b)},_handleSecondaryValue:function(a,b){this._lastSecondary=a,this._lastSecondary||this._send(ja,null,b)},_handleSecondaryEnd:function(a,b){this._lastSecondary===ia&&this._send(ja,null,b)}}),I("skipWhileBy",{_init:function(){this._hasFalseyFromSecondary=!1},_handlePrimaryValue:function(a,b){this._hasFalseyFromSecondary&&this._send(ka,a,b)},_handleSecondaryValue:function(a,b){this._hasFalseyFromSecondary=this._hasFalseyFromSecondary||!a},_handleSecondaryEnd:function(a,b){this._hasFalseyFromSecondary||this._send(ja,null,b)}}),"function"==typeof define&&define.amd?(define([],function(){return ha}),a.Kefir=ha):"object"==typeof module&&"object"==typeof exports?(module.exports=ha,ha.Kefir=ha):a.Kefir=ha}(this);
//# sourceMappingURL=kefir.min.js.map
{
"name": "kefir",
"version": "2.0.2",
"version": "2.1.0",
"description": "Reactive Programming library for JavaScript inspired by Bacon.js and RxJS with focus on high performance and low memory usage",

@@ -5,0 +5,0 @@ "main": "dist/kefir.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc