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 0.2.9 to 0.2.10

10

changelog.md

@@ -0,5 +1,11 @@

## 0.2.10
- Method `.transform` renamed to `.flatten`
- New method `.slidingWindow`
## 0.2.9
- The `fn` argument in the `.transform` method is now optional.
- Transducers support via `.transduce` method.
- The `fn` argument in the `.transform` method is now optional
- Transducers support via `.transduce` method

@@ -6,0 +12,0 @@

2

dist/addons/kefir-jquery.js

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

/*! An addon for Kefir.js v0.2.9
/*! An addon for Kefir.js v0.2.10
* https://github.com/pozadi/kefir

@@ -3,0 +3,0 @@ */

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

/*! An addon for Kefir.js v0.2.9
/*! An addon for Kefir.js v0.2.10
* https://github.com/pozadi/kefir

@@ -3,0 +3,0 @@ */

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

/*! Kefir.js v0.2.9
/*! Kefir.js v0.2.10
* https://github.com/pozadi/kefir

@@ -278,2 +278,14 @@ */

function slide(cur, next, max) {
var length = Math.min(max, cur.length + 1),
offset = cur.length - length + 1,
result = new Array(length),
i;
for (i = offset; i < length; i++) {
result[i - offset] = cur[i];
}
result[length - 1] = next;
return result;
}
var now = Date.now ?

@@ -1401,5 +1413,5 @@ function() { return Date.now() } :

// .transform(fn)
// .flatten(fn)
withOneSource('transform', {
withOneSource('flatten', {
_init: function(args) {

@@ -1663,3 +1675,3 @@ this._fn = args[0] ? Fn(args[0], 1) : null;

},
_free: function(){
_free: function() {
this._fn = null;

@@ -1680,3 +1692,25 @@ this._result = null;

// .slidingWindow(max[, min])
withOneSource('slidingWindow', {
_init: function(args) {
this._max = args[0];
this._min = args[1] || 0;
this._cache = [];
},
_free: function() {
this._cache = null;
},
_handleValue: function(x, isCurrent) {
this._cache = slide(this._cache, x, this._max);
if (this._cache.length >= this._min) {
this._send('value', this._cache, isCurrent);
}
}
});
// .debounce(wait, {immediate})

@@ -1683,0 +1717,0 @@

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

/*! Kefir.js v0.2.9
/*! Kefir.js v0.2.10
* https://github.com/pozadi/kefir
*/
!function(a){"use strict";function b(a,b,c){return a&&b in a?a[b]:c}function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function d(a){var b=function(){};return b.prototype=a,new b}function e(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 f(a,b){var c,f=arguments.length;for(a.prototype=d(b.prototype),a.prototype.constructor=a,c=2;f>c;c++)e(a.prototype,arguments[c]);return a}function g(a){return 1===a.length&&ab(a[0])?a[0]:p(a)}function h(a,b){if(w(a))return a;if(null!=b&&w(b[a]))return b[a];throw new Error("Not a function: "+a+" in context: "+b)}function i(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 j(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3];switch(c){case 0:switch(b.length){case 0:return a;case 1:return function(){return a(d)};case 2:return function(){return a(d,e)};case 3:return function(){return a(d,e,f)};case 4:return function(){return a(d,e,f,g)};default:return function(){return a.apply(null,b)}}break;case 1:switch(b.length){case 0:return a;case 1:return function(b){return a(d,b)};case 2:return function(b){return a(d,e,b)};case 3:return function(b){return a(d,e,f,b)};case 4:return function(b){return a(d,e,f,g,b)};default:return function(c){return a.apply(null,m(b,[c]))}}break;case 2:switch(b.length){case 0:return a;case 1:return function(b,c){return a(d,b,c)};case 2:return function(b,c){return a(d,e,b,c)};case 3:return function(b,c){return a(d,e,f,b,c)};case 4:return function(b,c){return a(d,e,f,g,b,c)};default:return function(c,d){return a.apply(null,m(b,[c,d]))}}break;default:switch(b.length){case 0:return a;default:return function(){return i(a,null,m(b,arguments))}}}}function k(a,b,c,d){var e=c[0],f=c[1],g=c[2],h=c[3];switch(d){case 0:switch(c.length){case 0:return function(){return a.call(b)};default:return function(){return a.apply(b,c)}}break;case 1:switch(c.length){case 0:return function(c){return a.call(b,c)};case 1:return function(c){return a.call(b,e,c)};case 2:return function(c){return a.call(b,e,f,c)};case 3:return function(c){return a.call(b,e,f,g,c)};case 4:return function(c){return a.call(b,e,f,g,h,c)};default:return function(d){return a.apply(b,m(c,[d]))}}break;case 2:switch(c.length){case 0:return function(c,d){return a.call(b,c,d)};case 1:return function(c,d){return a.call(b,e,c,d)};case 2:return function(c,d){return a.call(b,e,f,c,d)};case 3:return function(c,d){return a.call(b,e,f,g,c,d)};case 4:return function(c,d){return a.call(b,e,f,g,h,c,d)};default:return function(d,e){return a.apply(b,m(c,[d,e]))}}break;default:switch(c.length){case 0:return function(){return a.apply(b,arguments)};default:return function(){return a.apply(b,m(c,arguments))}}}}function l(a,b,c,d){return null==b?j(a,c,d):k(a,b,c,d)}function m(a,b){var c,d,e=new Array(a.length+b.length),f=0;if(0===a.length)return b;if(0===b.length)return a;for(c=a.length,d=0;c>d;d++,f++)e[f]=a[d];for(c=b.length,d=0;c>d;d++,f++)e[f]=b[d];return e}function n(a,b){var c,d=a.length;for(c=0;d>c;c++)if(a[c]===b)return c;return-1}function o(a,b){var c,d=a.length;for(c=0;d>c;c++)if(b(a[c]))return c;return-1}function p(a){var b,c=a.length,d=new Array(c);for(b=0;c>b;b++)d[b]=a[b];return d}function q(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 r(a,b){return q(a,o(a,b))}function s(a,b){var c,d=a.length;for(c=0;d>c;c++)b(a[c])}function t(a,b){var c,d=a.length;for(c=0;d>c;c++)a[c]=b}function u(a,b){return-1!==n(a,b)}function v(a,b,c){return a.length>b?Array.prototype.slice.call(a,b):c}function w(a){return"function"==typeof a}function x(a){return ab(a)||bb(a)}function y(a,b){var c,d;if(null==a&&null==b)return!0;if(null==a||null==b)return!1;if(a.length!==b.length)return!1;for(d=0,c=a.length;c>d;d++)if(a[d]!==b[d])return!1;return!0}function z(){for(var a=0;a<arguments.length;a++)if(!arguments[a])return arguments[a];return arguments[a-1]}function A(){for(var a=0;a<arguments.length;a++)if(arguments[a])return arguments[a];return arguments[a-1]}function B(a,b){function c(a,b){K.call(this),this._wait=a,this._intervalId=null;var c=this;this._$onTick=function(){c._onTick()},this._init(b)}f(c,K,{_name:a,_init:function(){},_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(){K.prototype._clear.call(this),this._$onTick=null,this._free()}},b),cb[a]=function(a){return new c(a,v(arguments,1,[]))}}function C(a,b,c){function d(c){function d(b,d){c.call(this),this._source=b,this._name=b._name+"."+a,this._init(d)}return f(d,c,{_clear:function(){c.prototype._clear.call(this),this._source=null,this._free()}},b),d}c=e({streamMethod:function(a){return function(){return new a(this,arguments)}},propertyMethod:function(a,b){return function(){return new b(this,arguments)}}},c||{}),b=e({_init:function(){},_free:function(){},_handleValue:function(a,b){this._send("value",a,b)},_handleEnd:function(a,b){this._send("end",null,b)},_onActivationHook:function(){},_onDeactivationHook:function(){},_handleAny:function(a){switch(a.type){case"value":this._handleValue(a.value,a.current);break;case"end":this._handleEnd(a.value,a.current)}},_onActivation:function(){this._onActivationHook(),this._source.onAny([this._handleAny,this])},_onDeactivation:function(){this._onDeactivationHook(),this._source.offAny([this._handleAny,this])}},b||{});var g=d(K),h=d(L);c.streamMethod&&(K.prototype[a]=c.streamMethod(g,h)),c.propertyMethod&&(L.prototype[a]=c.propertyMethod(g,h))}function D(a){if(a instanceof F)return a;if(w(a))return{fn:a,context:null,args:[]};if(x(a))return{fn:h(a[0],a[1]),context:null==a[1]?null:a[1],args:v(a,2,[])};throw new Error("Object isn't a function, and can't be converted to it: "+a)}function E(a,b){return a=D(a),i(a.fn,a.context,m(a.args,b))}function F(a,b){this.context=a.context,this.fn=a.fn,this.args=a.args,this.invoke=l(this.fn,this.context,this.args,b)}function G(a,b){return a instanceof F?a:new F(D(a),null==b?100:b)}function H(){this._fns=[]}function I(a,b,c){return{type:a,value:b,current:!!c}}function J(){this._subscribers=new H,this._active=!1,this._alive=!0}function K(){J.call(this)}function L(){J.call(this),this._current=$}function M(a,b){var c="<"+b.type+(b.current?":current":"")+">";"value"===b.type?console.log(a,c,b.value):console.log(a,c)}function N(a){if(K.call(this),this._queueLim=b(a,"queueLim",0),this._concurLim=b(a,"concurLim",-1),this._drop=b(a,"drop","new"),0===this._concurLim)throw new Error("options.concurLim can't be 0");this._queue=[],this._curSources=[],this._activating=!1}function O(a){N.call(this),0===a.length?this._send("end"):this._addAll(a),this._initialised=!0}function P(a){N.call(this,{concurLim:1,queueLim:-1}),0===a.length?this._send("end"):this._addAll(a),this._initialised=!0}function Q(){N.call(this)}function R(){N.call(this)}function S(a,b,c){N.call(this,c),this._source=a,this._fn=b?G(b,1):null,this._mainEnded=!1,this._lastCurrent=null}function T(a,b,c){K.call(this),0===b.length?this._send("end"):(this._passiveCount=a.length,this._combinator=c?G(c):null,this._sources=m(a,b),this._aliveCount=0,this._currents=new Array(this._sources.length),t(this._currents,$),this._activating=!1,this._emitAfterActivation=!1,this._endAfterActivation=!1)}function U(a){return function(){return new a(this,arguments)}}function V(a,b){return function(){return new b(this,arguments)}}function W(a){return{init:function(){return null},step:function(b,c){return a._send("value",c,a._forcedCurrent),null},result:function(){return a._send("end",null,a._forcedCurrent),null}}}function X(a){K.call(this),this._fn=G(a,1),this._unsubscribe=null}function Y(){K.call(this)}function Z(a){L.call(this),this._send("value",a),this._send("end")}var $=["<nothing>"],_=Date.now?function(){return Date.now()}:function(){return(new Date).getTime()},ab=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},bb=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};bb(arguments)||(bb=function(a){return!(!a||!c(a,"callee"))});var cb={};F.prototype.apply=function(a){return i(this.invoke,null,a)},F.prototype.applyWithContext=function(a,b){return null===this.context?i(this.fn,a,m(this.args,b)):this.apply(b)},G.isEqual=function(a,b){return a===b?!0:(a=G(a,null,!0),b=G(b,null,!0),a.fn===b.fn&&a.context===b.context&&y(a.args,b.args))},cb.Fn=G,e(H,{callOne:function(a,b){"any"===a.type?a.invoke(b):a.type===b.type&&("value"===a.type?a.invoke(b.value):a.invoke())},callOnce:function(a,b,c){"any"===a?E(b,[c]):a===c.type&&("value"===a?E(b,[c.value]):E(b,[]))}}),e(H.prototype,{add:function(a,b){b=G(b,"end"===a?0:1),b.type=a,this._fns=m(this._fns,[b])},remove:function(a,b){b=G(b),this._fns=r(this._fns,function(c){return c.type===a&&G.isEqual(c,b)})},callAll:function(a){for(var b=this._fns,c=0;c<b.length;c++)H.callOne(b[c],a)},isEmpty:function(){return 0===this._fns.length}});var db=I("end",void 0,!0);cb.Observable=J,e(J.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._subscribers=null},_send:function(a,b,c){this._alive&&(this._subscribers.callAll(I(a,b,c)),"end"===a&&this._clear())},on:function(a,b){return this._alive?(this._subscribers.add(a,b),this._setActive(!0)):H.callOnce(a,b,db),this},off:function(a,b){return this._alive&&(this._subscribers.remove(a,b),this._subscribers.isEmpty()&&this._setActive(!1)),this},onValue:function(a){return this.on("value",a)},onEnd:function(a){return this.on("end",a)},onAny:function(a){return this.on("any",a)},offValue:function(a){return this.off("value",a)},offEnd:function(a){return this.off("end",a)},offAny:function(a){return this.off("any",a)}}),J.prototype.toString=function(){return"["+this._name+"]"},cb.Stream=K,f(K,J,{_name:"stream"}),cb.Property=L,f(L,J,{_name:"property",_send:function(a,b,c){this._alive&&(c||this._subscribers.callAll(I(a,b)),"value"===a&&(this._current=b),"end"===a&&this._clear())},on:function(a,b){return this._alive&&(this._subscribers.add(a,b),this._setActive(!0)),this._current!==$&&H.callOnce(a,b,I("value",this._current,!0)),this._alive||H.callOnce(a,b,db),this}}),J.prototype.log=function(a){return this.onAny([M,null,a||this.toString()]),this},J.prototype.offLog=function(a){return this.offAny([M,null,a||this.toString()]),this},B("withInterval",{_init:function(a){this._fn=G(a[0],1);var b=this;this._emitter={emit:function(a){b._send("value",a)},end:function(){b._send("end")}}},_free:function(){this._fn=null,this._emitter=null},_onTick:function(){this._fn.invoke(this._emitter)}}),B("fromPoll",{_init:function(a){this._fn=G(a[0],0)},_free:function(){this._fn=null},_onTick:function(){this._send("value",this._fn.invoke())}}),B("interval",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send("value",this._x)}}),B("sequentially",{_init:function(a){this._xs=p(a[0]),0===this._xs.length&&this._send("end")},_free:function(){this._xs=null},_onTick:function(){switch(this._xs.length){case 1:this._send("value",this._xs[0]),this._send("end");break;default:this._send("value",this._xs.shift())}}}),B("repeatedly",{_init:function(a){this._xs=p(a[0]),this._i=-1},_onTick:function(){this._xs.length>0&&(this._i=(this._i+1)%this._xs.length,this._send("value",this._xs[this._i]))}}),B("later",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send("value",this._x),this._send("end")}}),f(N,K,{_name:"abstractPool",_add:function(a){-1===this._concurLim||this._curSources.length<this._concurLim?this._addToCur(a):-1===this._queueLim||this._queue.length<this._queueLim?this._addToQueue(a):"old"===this._drop&&(this._removeOldest(),this._add(a))},_addAll:function(a){var b=this;s(a,function(a){b._add(a)})},_remove:function(a){-1===this._removeCur(a)&&this._removeQueue(a)},_addToQueue:function(a){this._queue=m(this._queue,[a])},_addToCur:function(a){this._curSources=m(this._curSources,[a]),this._active&&this._sub(a)},_sub:function(a){a.onAny([this._handleSubAny,this]),a.onEnd([this._removeCur,this,a])},_unsub:function(a){a.offAny([this._handleSubAny,this]),a.offEnd([this._removeCur,this,a])},_handleSubAny:function(a){"value"===a.type&&this._send("value",a.value,a.current&&this._activating)},_removeQueue:function(a){var b=n(this._queue,a);return this._queue=q(this._queue,b),b},_removeCur:function(a){this._active&&this._unsub(a);var b=n(this._curSources,a);return this._curSources=q(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=p(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._sub(b[a]);this._activating=!1},_onDeactivation:function(){var a,b=this._curSources;for(a=0;a<b.length;a++)this._unsub(b[a])},_isEmpty:function(){return 0===this._curSources.length},_onEmpty:function(){},_clear:function(){K.prototype._clear.call(this),this._queue=null,this._curSources=null}});var eb={_onEmpty:function(){this._initialised&&this._send("end",null,this._activating)}};f(O,N,e({_name:"merge"},eb)),cb.merge=function(){return new O(g(arguments))},J.prototype.merge=function(a){return cb.merge([this,a])},f(P,N,e({_name:"concat"},eb)),cb.concat=function(){return new P(g(arguments))},J.prototype.concat=function(a){return cb.concat([this,a])},f(Q,N,{_name:"pool",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this}}),cb.pool=function(){return new Q},f(R,N,{_name:"bus",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this},emit:function(a){return this._send("value",a),this},end:function(){return this._send("end"),this}}),cb.bus=function(){return new R},f(S,N,{_onActivation:function(){N.prototype._onActivation.call(this),this._activating=!0,this._source.onAny([this._handleMainSource,this]),this._activating=!1},_onDeactivation:function(){N.prototype._onDeactivation.call(this),this._source.offAny([this._handleMainSource,this])},_handleMainSource:function(a){"value"===a.type?(a.current&&this._lastCurrent===a.value||this._add(this._fn?this._fn.invoke(a.value):a.value),this._lastCurrent=a.value):this._isEmpty()?this._send("end",null,a.current):this._mainEnded=!0},_onEmpty:function(){this._mainEnded&&this._send("end")},_clear:function(){N.prototype._clear.call(this),this._source=null,this._lastCurrent=null}}),J.prototype.flatMap=function(a){return new S(this,a).setName(this,"flatMap")},J.prototype.flatMapLatest=function(a){return new S(this,a,{concurLim:1,drop:"old"}).setName(this,"flatMapLatest")},J.prototype.flatMapFirst=function(a){return new S(this,a,{concurLim:1}).setName(this,"flatMapFirst")},J.prototype.flatMapConcat=function(a){return new S(this,a,{queueLim:-1,concurLim:1}).setName(this,"flatMapConcat")},J.prototype.flatMapConcurLimit=function(a,b){var c;return 0===b?c=cb.never():(0>b&&(b=-1),c=new S(this,a,{queueLim:-1,concurLim:b})),c.setName(this,"flatMapConcurLimit")},f(T,K,{_name:"sampledBy",_onActivation:function(){var a,b=this._sources.length;for(this._aliveCount=b-this._passiveCount,this._activating=!0,a=0;b>a;a++)this._sources[a].onAny([this._handleAny,this,a]);this._activating=!1,this._emitAfterActivation&&(this._emitAfterActivation=!1,this._emitIfFull(!0)),this._endAfterActivation&&this._send("end",null,!0)},_onDeactivation:function(){var a,b=this._sources.length;for(a=0;b>a;a++)this._sources[a].offAny([this._handleAny,this,a])},_emitIfFull:function(a){if(!u(this._currents,$)){var b=p(this._currents);this._combinator&&(b=this._combinator.apply(this._currents)),this._send("value",b,a)}},_handleAny:function(a,b){"value"===b.type?(this._currents[a]=b.value,a>=this._passiveCount&&(this._activating?this._emitAfterActivation=!0:this._emitIfFull(b.current))):a>=this._passiveCount&&(this._aliveCount--,0===this._aliveCount&&(this._activating?this._endAfterActivation=!0:this._send("end",null,b.current)))},_clear:function(){K.prototype._clear.call(this),this._sources=null,this._currents=null}}),cb.sampledBy=function(a,b,c){return new T(a,b,c)},J.prototype.sampledBy=function(a,b){return cb.sampledBy([this],[a],b)},cb.combine=function(a,b){var c=new T([],a,b);return c._name="combine",c},J.prototype.combine=function(a,b){return cb.combine([this,a],b)},C("toProperty",{_init:function(a){a.length>0&&this._send("value",a[0])}},{propertyMethod:null,streamMethod:V}),C("changes",{_handleValue:function(a,b){b||this._send("value",a)}},{streamMethod:null,propertyMethod:U}),C("withHandler",{_init:function(a){this._handler=G(a[0],2),this._forcedCurrent=!1;var b=this;this._emitter={emit:function(a){b._send("value",a,b._forcedCurrent)},end:function(){b._send("end",null,b._forcedCurrent)}}},_free:function(){this._handler=null,this._emitter=null},_handleAny:function(a){this._forcedCurrent=a.current,this._handler.invoke(this._emitter,a),this._forcedCurrent=!1}}),C("transform",{_init:function(a){this._fn=a[0]?G(a[0],1):null},_free:function(){this._fn=null},_handleValue:function(a,b){for(var c=null===this._fn?a:this._fn.invoke(a),d=0;d<c.length;d++)this._send("value",c[d],b)}}),C("transduce",{_init:function(a){this._xform=a[0](W(this)),this._forcedCurrent=!0,this._endIfReduced(this._xform.init()),this._forcedCurrent=!1},_free:function(){this._xform=null},_endIfReduced:function(a){null!==a&&this._xform.result(null)},_handleValue:function(a,b){this._forcedCurrent=b,this._endIfReduced(this._xform.step(null,a)),this._forcedCurrent=!1},_handleEnd:function(a,b){this._forcedCurrent=b,this._xform.result(null),this._forcedCurrent=!1}});var fb={_init:function(a){this._fn=G(a[0],1)},_free:function(){this._fn=null}};C("map",e({_handleValue:function(a,b){this._send("value",this._fn.invoke(a),b)}},fb)),C("filter",e({_handleValue:function(a,b){this._fn.invoke(a)&&this._send("value",a,b)}},fb)),C("takeWhile",e({_handleValue:function(a,b){this._fn.invoke(a)?this._send("value",a,b):this._send("end",null,b)}},fb)),C("take",{_init:function(a){this._n=a[0],this._n<=0&&this._send("end")},_handleValue:function(a,b){this._n--,this._send("value",a,b),0===this._n&&this._send("end")}}),C("skip",{_init:function(a){this._n=a[0]<0?0:a[0]},_handleValue:function(a,b){0===this._n?this._send("value",a,b):this._n--}}),C("skipDuplicates",{_init:function(a){this._fn=a[0]?G(a[0],2):null,this._prev=$},_free:function(){this._fn=null,this._prev=null},_isEqual:function(a,b){return null===this._fn?a===b:this._fn.invoke(a,b)},_handleValue:function(a,b){this._prev!==$&&this._isEqual(this._prev,a)||(this._send("value",a,b),this._prev=a)}}),C("skipWhile",{_init:function(a){this._fn=G(a[0],1),this._skip=!0},_free:function(){this._fn=null},_handleValue:function(a,b){return this._skip?void(this._fn.invoke(a)||(this._skip=!1,this._fn=null,this._send("value",a,b))):void this._send("value",a,b)}}),C("diff",{_init:function(a){this._prev=a[0],this._fn=G(a[1],2)},_free:function(){this._prev=null,this._fn=null},_handleValue:function(a,b){this._send("value",this._fn.invoke(this._prev,a),b),this._prev=a}}),C("scan",{_init:function(a){this._send("value",a[0],!0),this._fn=G(a[1],2)},_free:function(){this._fn=null},_handleValue:function(a,b){this._send("value",this._fn.invoke(this._current,a),b)}},{streamMethod:V}),C("reduce",{_init:function(a){this._result=a[0],this._fn=G(a[1],2)},_free:function(){this._fn=null,this._result=null},_handleValue:function(a){this._result=this._fn.invoke(this._result,a)},_handleEnd:function(a,b){this._send("value",this._result,b),this._send("end",null,b)}}),C("debounce",{_init:function(a){this._wait=Math.max(0,a[0]),this._immediate=b(a[1],"immediate",!1),this._lastAttempt=0,this._timeoutId=null,this._laterValue=null,this._endLater=!1;var c=this;this._$later=function(){c._later()}},_free:function(){this._laterValue=null,this._$later=null},_handleValue:function(a,b){b?this._send("value",a,b):(this._lastAttempt=_(),this._immediate&&!this._timeoutId&&this._send("value",a),this._timeoutId||(this._timeoutId=setTimeout(this._$later,this._wait)),this._immediate||(this._laterValue=a))},_handleEnd:function(a,b){b?this._send("end",null,b):this._timeoutId&&!this._immediate?this._endLater=!0:this._send("end")},_later:function(){var a=_()-this._lastAttempt;a<this._wait&&a>=0?this._timeoutId=setTimeout(this._$later,this._wait-a):(this._timeoutId=null,this._immediate||(this._send("value",this._laterValue),this._laterValue=null),this._endLater&&this._send("end"))}}),C("throttle",{_init:function(a){this._wait=Math.max(0,a[0]),this._leading=b(a[1],"leading",!0),this._trailing=b(a[1],"trailing",!0),this._trailingValue=null,this._timeoutId=null,this._endLater=!1,this._lastCallTime=0;var c=this;this._$trailingCall=function(){c._trailingCall()}},_free:function(){this._trailingValue=null,this._$trailingCall=null},_handleValue:function(a,b){if(b)this._send("value",a,b);else{var c=_();0!==this._lastCallTime||this._leading||(this._lastCallTime=c);var d=this._wait-(c-this._lastCallTime);0>=d?(this._cancelTraling(),this._lastCallTime=c,this._send("value",a)):this._trailing&&(this._cancelTraling(),this._trailingValue=a,this._timeoutId=setTimeout(this._$trailingCall,d))}},_handleEnd:function(a,b){b?this._send("end",null,b):this._timeoutId?this._endLater=!0:this._send("end")},_cancelTraling:function(){null!==this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=null)},_trailingCall:function(){this._send("value",this._trailingValue),this._timeoutId=null,this._trailingValue=null,this._lastCallTime=this._leading?_():0,this._endLater&&this._send("end")}}),C("delay",{_init:function(a){this._wait=Math.max(0,a[0]),this._buff=[];var b=this;this._$shiftBuff=function(){b._send("value",b._buff.shift())}},_free:function(){this._buff=null,this._$shiftBuff=null},_handleValue:function(a,b){b?this._send("value",a,b):(this._buff.push(a),setTimeout(this._$shiftBuff,this._wait))},_handleEnd:function(a,b){if(b)this._send("end",null,b);else{var c=this;setTimeout(function(){c._send("end")},this._wait)}}}),f(X,K,{_name:"fromBinder",_onActivation:function(){var a,b=this,c=!0,d={emit:function(a){b._send("value",a,c)},end:function(){b._send("end",null,c)}};a=this._fn.invoke(d),c=!1,a&&(this._unsubscribe=G(a,0))},_onDeactivation:function(){null!==this._unsubscribe&&(this._unsubscribe.invoke(),this._unsubscribe=null)},_clear:function(){K.prototype._clear.call(this),this._fn=null}}),cb.fromBinder=function(a){return new X(a)},f(Y,K,{_name:"emitter",emit:function(a){return this._send("value",a),this},end:function(){return this._send("end"),this}}),cb.emitter=function(){return new Y};var gb=new K;gb._send("end"),gb._name="never",cb.never=function(){return gb},f(Z,L,{_name:"constant"}),cb.constant=function(a){return new Z(a)},J.prototype.setName=function(a,b){return this._name=b?a._name+"."+b:a,this},J.prototype.mapTo=function(a){return this.map(function(){return a}).setName(this,"mapTo")},J.prototype.pluck=function(a){return this.map(function(b){return b[a]}).setName(this,"pluck")},J.prototype.invoke=function(a){var b=v(arguments,1);return this.map(b?function(c){return i(c[a],c,b)}:function(b){return b[a]()}).setName(this,"invoke")},J.prototype.timestamp=function(){return this.map(function(a){return{value:a,time:_()}}).setName(this,"timestamp")},J.prototype.tap=function(a){return a=G(a,1),this.map(function(b){return a.invoke(b),b}).setName(this,"tap")},cb.and=function(a){return cb.combine(a,z).setName("and")},J.prototype.and=function(a){return this.combine(a,z).setName("and")},cb.or=function(a){return cb.combine(a,A).setName("or")},J.prototype.or=function(a){return this.combine(a,A).setName("or")},J.prototype.not=function(){return this.map(function(a){return!a}).setName(this,"not")},J.prototype.awaiting=function(a){return cb.merge([this.mapTo(!0),a.mapTo(!1)]).skipDuplicates().toProperty(!1).setName(this,"awaiting")},J.prototype.filterBy=function(a){return a.sampledBy(this).withHandler(function(a,b){"end"===b.type?a.end():b.value[0]&&a.emit(b.value[1])}).setName(this,"filterBy")},cb.fromCallback=function(a){a=G(a,1);var b=!1;return cb.fromBinder(function(c){b||(a.invoke(function(a){c.emit(a),c.end()}),b=!0)}).setName("fromCallback")},cb.fromEvent=function(a,b,c){c=c&&G(c);var d=a.addEventListener||a.addListener||a.bind,e=a.removeEventListener||a.removeListener||a.unbind;return cb.fromBinder(function(f){var g=c?function(){f.emit(c.applyWithContext(this,arguments))}:f.emit;return d.call(a,b,g),function(){e.call(a,b,g)}}).setName("fromEvent")},"function"==typeof define&&define.amd?(define([],function(){return cb}),a.Kefir=cb):"object"==typeof module&&"object"==typeof exports?(module.exports=cb,cb.Kefir=cb):a.Kefir=cb}(this);
!function(a){"use strict";function b(a,b,c){return a&&b in a?a[b]:c}function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function d(a){var b=function(){};return b.prototype=a,new b}function e(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 f(a,b){var c,f=arguments.length;for(a.prototype=d(b.prototype),a.prototype.constructor=a,c=2;f>c;c++)e(a.prototype,arguments[c]);return a}function g(a){return 1===a.length&&bb(a[0])?a[0]:p(a)}function h(a,b){if(x(a))return a;if(null!=b&&x(b[a]))return b[a];throw new Error("Not a function: "+a+" in context: "+b)}function i(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 j(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3];switch(c){case 0:switch(b.length){case 0:return a;case 1:return function(){return a(d)};case 2:return function(){return a(d,e)};case 3:return function(){return a(d,e,f)};case 4:return function(){return a(d,e,f,g)};default:return function(){return a.apply(null,b)}}break;case 1:switch(b.length){case 0:return a;case 1:return function(b){return a(d,b)};case 2:return function(b){return a(d,e,b)};case 3:return function(b){return a(d,e,f,b)};case 4:return function(b){return a(d,e,f,g,b)};default:return function(c){return a.apply(null,m(b,[c]))}}break;case 2:switch(b.length){case 0:return a;case 1:return function(b,c){return a(d,b,c)};case 2:return function(b,c){return a(d,e,b,c)};case 3:return function(b,c){return a(d,e,f,b,c)};case 4:return function(b,c){return a(d,e,f,g,b,c)};default:return function(c,d){return a.apply(null,m(b,[c,d]))}}break;default:switch(b.length){case 0:return a;default:return function(){return i(a,null,m(b,arguments))}}}}function k(a,b,c,d){var e=c[0],f=c[1],g=c[2],h=c[3];switch(d){case 0:switch(c.length){case 0:return function(){return a.call(b)};default:return function(){return a.apply(b,c)}}break;case 1:switch(c.length){case 0:return function(c){return a.call(b,c)};case 1:return function(c){return a.call(b,e,c)};case 2:return function(c){return a.call(b,e,f,c)};case 3:return function(c){return a.call(b,e,f,g,c)};case 4:return function(c){return a.call(b,e,f,g,h,c)};default:return function(d){return a.apply(b,m(c,[d]))}}break;case 2:switch(c.length){case 0:return function(c,d){return a.call(b,c,d)};case 1:return function(c,d){return a.call(b,e,c,d)};case 2:return function(c,d){return a.call(b,e,f,c,d)};case 3:return function(c,d){return a.call(b,e,f,g,c,d)};case 4:return function(c,d){return a.call(b,e,f,g,h,c,d)};default:return function(d,e){return a.apply(b,m(c,[d,e]))}}break;default:switch(c.length){case 0:return function(){return a.apply(b,arguments)};default:return function(){return a.apply(b,m(c,arguments))}}}}function l(a,b,c,d){return null==b?j(a,c,d):k(a,b,c,d)}function m(a,b){var c,d,e=new Array(a.length+b.length),f=0;if(0===a.length)return b;if(0===b.length)return a;for(c=a.length,d=0;c>d;d++,f++)e[f]=a[d];for(c=b.length,d=0;c>d;d++,f++)e[f]=b[d];return e}function n(a,b){var c,d=a.length;for(c=0;d>c;c++)if(a[c]===b)return c;return-1}function o(a,b){var c,d=a.length;for(c=0;d>c;c++)if(b(a[c]))return c;return-1}function p(a){var b,c=a.length,d=new Array(c);for(b=0;c>b;b++)d[b]=a[b];return d}function q(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 r(a,b){return q(a,o(a,b))}function s(a,b){var c,d=a.length;for(c=0;d>c;c++)b(a[c])}function t(a,b){var c,d=a.length;for(c=0;d>c;c++)a[c]=b}function u(a,b){return-1!==n(a,b)}function v(a,b,c){return a.length>b?Array.prototype.slice.call(a,b):c}function w(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 x(a){return"function"==typeof a}function y(a){return bb(a)||cb(a)}function z(a,b){var c,d;if(null==a&&null==b)return!0;if(null==a||null==b)return!1;if(a.length!==b.length)return!1;for(d=0,c=a.length;c>d;d++)if(a[d]!==b[d])return!1;return!0}function A(){for(var a=0;a<arguments.length;a++)if(!arguments[a])return arguments[a];return arguments[a-1]}function B(){for(var a=0;a<arguments.length;a++)if(arguments[a])return arguments[a];return arguments[a-1]}function C(a,b){function c(a,b){L.call(this),this._wait=a,this._intervalId=null;var c=this;this._$onTick=function(){c._onTick()},this._init(b)}f(c,L,{_name:a,_init:function(){},_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(){L.prototype._clear.call(this),this._$onTick=null,this._free()}},b),db[a]=function(a){return new c(a,v(arguments,1,[]))}}function D(a,b,c){function d(c){function d(b,d){c.call(this),this._source=b,this._name=b._name+"."+a,this._init(d)}return f(d,c,{_clear:function(){c.prototype._clear.call(this),this._source=null,this._free()}},b),d}c=e({streamMethod:function(a){return function(){return new a(this,arguments)}},propertyMethod:function(a,b){return function(){return new b(this,arguments)}}},c||{}),b=e({_init:function(){},_free:function(){},_handleValue:function(a,b){this._send("value",a,b)},_handleEnd:function(a,b){this._send("end",null,b)},_onActivationHook:function(){},_onDeactivationHook:function(){},_handleAny:function(a){switch(a.type){case"value":this._handleValue(a.value,a.current);break;case"end":this._handleEnd(a.value,a.current)}},_onActivation:function(){this._onActivationHook(),this._source.onAny([this._handleAny,this])},_onDeactivation:function(){this._onDeactivationHook(),this._source.offAny([this._handleAny,this])}},b||{});var g=d(L),h=d(M);c.streamMethod&&(L.prototype[a]=c.streamMethod(g,h)),c.propertyMethod&&(M.prototype[a]=c.propertyMethod(g,h))}function E(a){if(a instanceof G)return a;if(x(a))return{fn:a,context:null,args:[]};if(y(a))return{fn:h(a[0],a[1]),context:null==a[1]?null:a[1],args:v(a,2,[])};throw new Error("Object isn't a function, and can't be converted to it: "+a)}function F(a,b){return a=E(a),i(a.fn,a.context,m(a.args,b))}function G(a,b){this.context=a.context,this.fn=a.fn,this.args=a.args,this.invoke=l(this.fn,this.context,this.args,b)}function H(a,b){return a instanceof G?a:new G(E(a),null==b?100:b)}function I(){this._fns=[]}function J(a,b,c){return{type:a,value:b,current:!!c}}function K(){this._subscribers=new I,this._active=!1,this._alive=!0}function L(){K.call(this)}function M(){K.call(this),this._current=_}function N(a,b){var c="<"+b.type+(b.current?":current":"")+">";"value"===b.type?console.log(a,c,b.value):console.log(a,c)}function O(a){if(L.call(this),this._queueLim=b(a,"queueLim",0),this._concurLim=b(a,"concurLim",-1),this._drop=b(a,"drop","new"),0===this._concurLim)throw new Error("options.concurLim can't be 0");this._queue=[],this._curSources=[],this._activating=!1}function P(a){O.call(this),0===a.length?this._send("end"):this._addAll(a),this._initialised=!0}function Q(a){O.call(this,{concurLim:1,queueLim:-1}),0===a.length?this._send("end"):this._addAll(a),this._initialised=!0}function R(){O.call(this)}function S(){O.call(this)}function T(a,b,c){O.call(this,c),this._source=a,this._fn=b?H(b,1):null,this._mainEnded=!1,this._lastCurrent=null}function U(a,b,c){L.call(this),0===b.length?this._send("end"):(this._passiveCount=a.length,this._combinator=c?H(c):null,this._sources=m(a,b),this._aliveCount=0,this._currents=new Array(this._sources.length),t(this._currents,_),this._activating=!1,this._emitAfterActivation=!1,this._endAfterActivation=!1)}function V(a){return function(){return new a(this,arguments)}}function W(a,b){return function(){return new b(this,arguments)}}function X(a){return{init:function(){return null},step:function(b,c){return a._send("value",c,a._forcedCurrent),null},result:function(){return a._send("end",null,a._forcedCurrent),null}}}function Y(a){L.call(this),this._fn=H(a,1),this._unsubscribe=null}function Z(){L.call(this)}function $(a){M.call(this),this._send("value",a),this._send("end")}var _=["<nothing>"],ab=Date.now?function(){return Date.now()}:function(){return(new Date).getTime()},bb=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},cb=function(a){return"[object Arguments]"===Object.prototype.toString.call(a)};cb(arguments)||(cb=function(a){return!(!a||!c(a,"callee"))});var db={};G.prototype.apply=function(a){return i(this.invoke,null,a)},G.prototype.applyWithContext=function(a,b){return null===this.context?i(this.fn,a,m(this.args,b)):this.apply(b)},H.isEqual=function(a,b){return a===b?!0:(a=H(a,null,!0),b=H(b,null,!0),a.fn===b.fn&&a.context===b.context&&z(a.args,b.args))},db.Fn=H,e(I,{callOne:function(a,b){"any"===a.type?a.invoke(b):a.type===b.type&&("value"===a.type?a.invoke(b.value):a.invoke())},callOnce:function(a,b,c){"any"===a?F(b,[c]):a===c.type&&("value"===a?F(b,[c.value]):F(b,[]))}}),e(I.prototype,{add:function(a,b){b=H(b,"end"===a?0:1),b.type=a,this._fns=m(this._fns,[b])},remove:function(a,b){b=H(b),this._fns=r(this._fns,function(c){return c.type===a&&H.isEqual(c,b)})},callAll:function(a){for(var b=this._fns,c=0;c<b.length;c++)I.callOne(b[c],a)},isEmpty:function(){return 0===this._fns.length}});var eb=J("end",void 0,!0);db.Observable=K,e(K.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._subscribers=null},_send:function(a,b,c){this._alive&&(this._subscribers.callAll(J(a,b,c)),"end"===a&&this._clear())},on:function(a,b){return this._alive?(this._subscribers.add(a,b),this._setActive(!0)):I.callOnce(a,b,eb),this},off:function(a,b){return this._alive&&(this._subscribers.remove(a,b),this._subscribers.isEmpty()&&this._setActive(!1)),this},onValue:function(a){return this.on("value",a)},onEnd:function(a){return this.on("end",a)},onAny:function(a){return this.on("any",a)},offValue:function(a){return this.off("value",a)},offEnd:function(a){return this.off("end",a)},offAny:function(a){return this.off("any",a)}}),K.prototype.toString=function(){return"["+this._name+"]"},db.Stream=L,f(L,K,{_name:"stream"}),db.Property=M,f(M,K,{_name:"property",_send:function(a,b,c){this._alive&&(c||this._subscribers.callAll(J(a,b)),"value"===a&&(this._current=b),"end"===a&&this._clear())},on:function(a,b){return this._alive&&(this._subscribers.add(a,b),this._setActive(!0)),this._current!==_&&I.callOnce(a,b,J("value",this._current,!0)),this._alive||I.callOnce(a,b,eb),this}}),K.prototype.log=function(a){return this.onAny([N,null,a||this.toString()]),this},K.prototype.offLog=function(a){return this.offAny([N,null,a||this.toString()]),this},C("withInterval",{_init:function(a){this._fn=H(a[0],1);var b=this;this._emitter={emit:function(a){b._send("value",a)},end:function(){b._send("end")}}},_free:function(){this._fn=null,this._emitter=null},_onTick:function(){this._fn.invoke(this._emitter)}}),C("fromPoll",{_init:function(a){this._fn=H(a[0],0)},_free:function(){this._fn=null},_onTick:function(){this._send("value",this._fn.invoke())}}),C("interval",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send("value",this._x)}}),C("sequentially",{_init:function(a){this._xs=p(a[0]),0===this._xs.length&&this._send("end")},_free:function(){this._xs=null},_onTick:function(){switch(this._xs.length){case 1:this._send("value",this._xs[0]),this._send("end");break;default:this._send("value",this._xs.shift())}}}),C("repeatedly",{_init:function(a){this._xs=p(a[0]),this._i=-1},_onTick:function(){this._xs.length>0&&(this._i=(this._i+1)%this._xs.length,this._send("value",this._xs[this._i]))}}),C("later",{_init:function(a){this._x=a[0]},_free:function(){this._x=null},_onTick:function(){this._send("value",this._x),this._send("end")}}),f(O,L,{_name:"abstractPool",_add:function(a){-1===this._concurLim||this._curSources.length<this._concurLim?this._addToCur(a):-1===this._queueLim||this._queue.length<this._queueLim?this._addToQueue(a):"old"===this._drop&&(this._removeOldest(),this._add(a))},_addAll:function(a){var b=this;s(a,function(a){b._add(a)})},_remove:function(a){-1===this._removeCur(a)&&this._removeQueue(a)},_addToQueue:function(a){this._queue=m(this._queue,[a])},_addToCur:function(a){this._curSources=m(this._curSources,[a]),this._active&&this._sub(a)},_sub:function(a){a.onAny([this._handleSubAny,this]),a.onEnd([this._removeCur,this,a])},_unsub:function(a){a.offAny([this._handleSubAny,this]),a.offEnd([this._removeCur,this,a])},_handleSubAny:function(a){"value"===a.type&&this._send("value",a.value,a.current&&this._activating)},_removeQueue:function(a){var b=n(this._queue,a);return this._queue=q(this._queue,b),b},_removeCur:function(a){this._active&&this._unsub(a);var b=n(this._curSources,a);return this._curSources=q(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=p(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._sub(b[a]);this._activating=!1},_onDeactivation:function(){var a,b=this._curSources;for(a=0;a<b.length;a++)this._unsub(b[a])},_isEmpty:function(){return 0===this._curSources.length},_onEmpty:function(){},_clear:function(){L.prototype._clear.call(this),this._queue=null,this._curSources=null}});var fb={_onEmpty:function(){this._initialised&&this._send("end",null,this._activating)}};f(P,O,e({_name:"merge"},fb)),db.merge=function(){return new P(g(arguments))},K.prototype.merge=function(a){return db.merge([this,a])},f(Q,O,e({_name:"concat"},fb)),db.concat=function(){return new Q(g(arguments))},K.prototype.concat=function(a){return db.concat([this,a])},f(R,O,{_name:"pool",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this}}),db.pool=function(){return new R},f(S,O,{_name:"bus",plug:function(a){return this._add(a),this},unplug:function(a){return this._remove(a),this},emit:function(a){return this._send("value",a),this},end:function(){return this._send("end"),this}}),db.bus=function(){return new S},f(T,O,{_onActivation:function(){O.prototype._onActivation.call(this),this._activating=!0,this._source.onAny([this._handleMainSource,this]),this._activating=!1},_onDeactivation:function(){O.prototype._onDeactivation.call(this),this._source.offAny([this._handleMainSource,this])},_handleMainSource:function(a){"value"===a.type?(a.current&&this._lastCurrent===a.value||this._add(this._fn?this._fn.invoke(a.value):a.value),this._lastCurrent=a.value):this._isEmpty()?this._send("end",null,a.current):this._mainEnded=!0},_onEmpty:function(){this._mainEnded&&this._send("end")},_clear:function(){O.prototype._clear.call(this),this._source=null,this._lastCurrent=null}}),K.prototype.flatMap=function(a){return new T(this,a).setName(this,"flatMap")},K.prototype.flatMapLatest=function(a){return new T(this,a,{concurLim:1,drop:"old"}).setName(this,"flatMapLatest")},K.prototype.flatMapFirst=function(a){return new T(this,a,{concurLim:1}).setName(this,"flatMapFirst")},K.prototype.flatMapConcat=function(a){return new T(this,a,{queueLim:-1,concurLim:1}).setName(this,"flatMapConcat")},K.prototype.flatMapConcurLimit=function(a,b){var c;return 0===b?c=db.never():(0>b&&(b=-1),c=new T(this,a,{queueLim:-1,concurLim:b})),c.setName(this,"flatMapConcurLimit")},f(U,L,{_name:"sampledBy",_onActivation:function(){var a,b=this._sources.length;for(this._aliveCount=b-this._passiveCount,this._activating=!0,a=0;b>a;a++)this._sources[a].onAny([this._handleAny,this,a]);this._activating=!1,this._emitAfterActivation&&(this._emitAfterActivation=!1,this._emitIfFull(!0)),this._endAfterActivation&&this._send("end",null,!0)},_onDeactivation:function(){var a,b=this._sources.length;for(a=0;b>a;a++)this._sources[a].offAny([this._handleAny,this,a])},_emitIfFull:function(a){if(!u(this._currents,_)){var b=p(this._currents);this._combinator&&(b=this._combinator.apply(this._currents)),this._send("value",b,a)}},_handleAny:function(a,b){"value"===b.type?(this._currents[a]=b.value,a>=this._passiveCount&&(this._activating?this._emitAfterActivation=!0:this._emitIfFull(b.current))):a>=this._passiveCount&&(this._aliveCount--,0===this._aliveCount&&(this._activating?this._endAfterActivation=!0:this._send("end",null,b.current)))},_clear:function(){L.prototype._clear.call(this),this._sources=null,this._currents=null}}),db.sampledBy=function(a,b,c){return new U(a,b,c)},K.prototype.sampledBy=function(a,b){return db.sampledBy([this],[a],b)},db.combine=function(a,b){var c=new U([],a,b);return c._name="combine",c},K.prototype.combine=function(a,b){return db.combine([this,a],b)},D("toProperty",{_init:function(a){a.length>0&&this._send("value",a[0])}},{propertyMethod:null,streamMethod:W}),D("changes",{_handleValue:function(a,b){b||this._send("value",a)}},{streamMethod:null,propertyMethod:V}),D("withHandler",{_init:function(a){this._handler=H(a[0],2),this._forcedCurrent=!1;var b=this;this._emitter={emit:function(a){b._send("value",a,b._forcedCurrent)},end:function(){b._send("end",null,b._forcedCurrent)}}},_free:function(){this._handler=null,this._emitter=null},_handleAny:function(a){this._forcedCurrent=a.current,this._handler.invoke(this._emitter,a),this._forcedCurrent=!1}}),D("flatten",{_init:function(a){this._fn=a[0]?H(a[0],1):null},_free:function(){this._fn=null},_handleValue:function(a,b){for(var c=null===this._fn?a:this._fn.invoke(a),d=0;d<c.length;d++)this._send("value",c[d],b)}}),D("transduce",{_init:function(a){this._xform=a[0](X(this)),this._forcedCurrent=!0,this._endIfReduced(this._xform.init()),this._forcedCurrent=!1},_free:function(){this._xform=null},_endIfReduced:function(a){null!==a&&this._xform.result(null)},_handleValue:function(a,b){this._forcedCurrent=b,this._endIfReduced(this._xform.step(null,a)),this._forcedCurrent=!1},_handleEnd:function(a,b){this._forcedCurrent=b,this._xform.result(null),this._forcedCurrent=!1}});var gb={_init:function(a){this._fn=H(a[0],1)},_free:function(){this._fn=null}};D("map",e({_handleValue:function(a,b){this._send("value",this._fn.invoke(a),b)}},gb)),D("filter",e({_handleValue:function(a,b){this._fn.invoke(a)&&this._send("value",a,b)}},gb)),D("takeWhile",e({_handleValue:function(a,b){this._fn.invoke(a)?this._send("value",a,b):this._send("end",null,b)}},gb)),D("take",{_init:function(a){this._n=a[0],this._n<=0&&this._send("end")},_handleValue:function(a,b){this._n--,this._send("value",a,b),0===this._n&&this._send("end")}}),D("skip",{_init:function(a){this._n=a[0]<0?0:a[0]},_handleValue:function(a,b){0===this._n?this._send("value",a,b):this._n--}}),D("skipDuplicates",{_init:function(a){this._fn=a[0]?H(a[0],2):null,this._prev=_},_free:function(){this._fn=null,this._prev=null},_isEqual:function(a,b){return null===this._fn?a===b:this._fn.invoke(a,b)},_handleValue:function(a,b){this._prev!==_&&this._isEqual(this._prev,a)||(this._send("value",a,b),this._prev=a)}}),D("skipWhile",{_init:function(a){this._fn=H(a[0],1),this._skip=!0},_free:function(){this._fn=null},_handleValue:function(a,b){return this._skip?void(this._fn.invoke(a)||(this._skip=!1,this._fn=null,this._send("value",a,b))):void this._send("value",a,b)}}),D("diff",{_init:function(a){this._prev=a[0],this._fn=H(a[1],2)},_free:function(){this._prev=null,this._fn=null},_handleValue:function(a,b){this._send("value",this._fn.invoke(this._prev,a),b),this._prev=a}}),D("scan",{_init:function(a){this._send("value",a[0],!0),this._fn=H(a[1],2)},_free:function(){this._fn=null},_handleValue:function(a,b){this._send("value",this._fn.invoke(this._current,a),b)}},{streamMethod:W}),D("reduce",{_init:function(a){this._result=a[0],this._fn=H(a[1],2)},_free:function(){this._fn=null,this._result=null},_handleValue:function(a){this._result=this._fn.invoke(this._result,a)},_handleEnd:function(a,b){this._send("value",this._result,b),this._send("end",null,b)}}),D("slidingWindow",{_init:function(a){this._max=a[0],this._min=a[1]||0,this._cache=[]},_free:function(){this._cache=null},_handleValue:function(a,b){this._cache=w(this._cache,a,this._max),this._cache.length>=this._min&&this._send("value",this._cache,b)}}),D("debounce",{_init:function(a){this._wait=Math.max(0,a[0]),this._immediate=b(a[1],"immediate",!1),this._lastAttempt=0,this._timeoutId=null,this._laterValue=null,this._endLater=!1;var c=this;this._$later=function(){c._later()}},_free:function(){this._laterValue=null,this._$later=null},_handleValue:function(a,b){b?this._send("value",a,b):(this._lastAttempt=ab(),this._immediate&&!this._timeoutId&&this._send("value",a),this._timeoutId||(this._timeoutId=setTimeout(this._$later,this._wait)),this._immediate||(this._laterValue=a))},_handleEnd:function(a,b){b?this._send("end",null,b):this._timeoutId&&!this._immediate?this._endLater=!0:this._send("end")},_later:function(){var a=ab()-this._lastAttempt;a<this._wait&&a>=0?this._timeoutId=setTimeout(this._$later,this._wait-a):(this._timeoutId=null,this._immediate||(this._send("value",this._laterValue),this._laterValue=null),this._endLater&&this._send("end"))}}),D("throttle",{_init:function(a){this._wait=Math.max(0,a[0]),this._leading=b(a[1],"leading",!0),this._trailing=b(a[1],"trailing",!0),this._trailingValue=null,this._timeoutId=null,this._endLater=!1,this._lastCallTime=0;var c=this;this._$trailingCall=function(){c._trailingCall()}},_free:function(){this._trailingValue=null,this._$trailingCall=null},_handleValue:function(a,b){if(b)this._send("value",a,b);else{var c=ab();0!==this._lastCallTime||this._leading||(this._lastCallTime=c);var d=this._wait-(c-this._lastCallTime);0>=d?(this._cancelTraling(),this._lastCallTime=c,this._send("value",a)):this._trailing&&(this._cancelTraling(),this._trailingValue=a,this._timeoutId=setTimeout(this._$trailingCall,d))}},_handleEnd:function(a,b){b?this._send("end",null,b):this._timeoutId?this._endLater=!0:this._send("end")},_cancelTraling:function(){null!==this._timeoutId&&(clearTimeout(this._timeoutId),this._timeoutId=null)},_trailingCall:function(){this._send("value",this._trailingValue),this._timeoutId=null,this._trailingValue=null,this._lastCallTime=this._leading?ab():0,this._endLater&&this._send("end")}}),D("delay",{_init:function(a){this._wait=Math.max(0,a[0]),this._buff=[];var b=this;this._$shiftBuff=function(){b._send("value",b._buff.shift())}},_free:function(){this._buff=null,this._$shiftBuff=null},_handleValue:function(a,b){b?this._send("value",a,b):(this._buff.push(a),setTimeout(this._$shiftBuff,this._wait))},_handleEnd:function(a,b){if(b)this._send("end",null,b);else{var c=this;setTimeout(function(){c._send("end")},this._wait)}}}),f(Y,L,{_name:"fromBinder",_onActivation:function(){var a,b=this,c=!0,d={emit:function(a){b._send("value",a,c)},end:function(){b._send("end",null,c)}};a=this._fn.invoke(d),c=!1,a&&(this._unsubscribe=H(a,0))},_onDeactivation:function(){null!==this._unsubscribe&&(this._unsubscribe.invoke(),this._unsubscribe=null)},_clear:function(){L.prototype._clear.call(this),this._fn=null}}),db.fromBinder=function(a){return new Y(a)},f(Z,L,{_name:"emitter",emit:function(a){return this._send("value",a),this},end:function(){return this._send("end"),this}}),db.emitter=function(){return new Z};var hb=new L;hb._send("end"),hb._name="never",db.never=function(){return hb},f($,M,{_name:"constant"}),db.constant=function(a){return new $(a)},K.prototype.setName=function(a,b){return this._name=b?a._name+"."+b:a,this},K.prototype.mapTo=function(a){return this.map(function(){return a}).setName(this,"mapTo")},K.prototype.pluck=function(a){return this.map(function(b){return b[a]}).setName(this,"pluck")},K.prototype.invoke=function(a){var b=v(arguments,1);return this.map(b?function(c){return i(c[a],c,b)}:function(b){return b[a]()}).setName(this,"invoke")},K.prototype.timestamp=function(){return this.map(function(a){return{value:a,time:ab()}}).setName(this,"timestamp")},K.prototype.tap=function(a){return a=H(a,1),this.map(function(b){return a.invoke(b),b}).setName(this,"tap")},db.and=function(a){return db.combine(a,A).setName("and")},K.prototype.and=function(a){return this.combine(a,A).setName("and")},db.or=function(a){return db.combine(a,B).setName("or")},K.prototype.or=function(a){return this.combine(a,B).setName("or")},K.prototype.not=function(){return this.map(function(a){return!a}).setName(this,"not")},K.prototype.awaiting=function(a){return db.merge([this.mapTo(!0),a.mapTo(!1)]).skipDuplicates().toProperty(!1).setName(this,"awaiting")},K.prototype.filterBy=function(a){return a.sampledBy(this).withHandler(function(a,b){"end"===b.type?a.end():b.value[0]&&a.emit(b.value[1])}).setName(this,"filterBy")},db.fromCallback=function(a){a=H(a,1);var b=!1;return db.fromBinder(function(c){b||(a.invoke(function(a){c.emit(a),c.end()}),b=!0)}).setName("fromCallback")},db.fromEvent=function(a,b,c){c=c&&H(c);var d=a.addEventListener||a.addListener||a.bind,e=a.removeEventListener||a.removeListener||a.unbind;return db.fromBinder(function(f){var g=c?function(){f.emit(c.applyWithContext(this,arguments))}:f.emit;return d.call(a,b,g),function(){e.call(a,b,g)}}).setName("fromEvent")},"function"==typeof define&&define.amd?(define([],function(){return db}),a.Kefir=db):"object"==typeof module&&"object"==typeof exports?(module.exports=db,db.Kefir=db):a.Kefir=db}(this);
//# sourceMappingURL=kefir.min.js.map
{
"name": "kefir",
"version": "0.2.9",
"version": "0.2.10",
"description": "FRP library for JavaScript inspired by Bacon.js and RxJS with focus on high performance and low memory consumption",

@@ -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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc